4.5.5 • Published 10 months ago

web3.storage v4.5.5

Weekly downloads
-
License
(Apache-2.0 OR MI...
Repository
github
Last release
10 months ago

Getting started

Install the package using npm

npm install web3.storage

Usage

The code below shows how you create a new web3.storage api client, and use it to put your files to web3, and get them back again.

Sign in to https://web3.storage, create an API token, and use it in place of API_TOKEN when creating your instance of the client.

import { Web3Storage } from 'web3.storage'

// Construct with token and endpoint
const client = new Web3Storage({ token: API_TOKEN })

const fileInput = document.querySelector('input[type="file"]')

// Pack files into a CAR and send to web3.storage
const rootCid = await client.put(fileInput.files) // Promise<CIDString>

// Get info on the Filecoin deals that the CID is stored in
const info = await client.status(rootCid) // Promise<Status | undefined>

// Fetch and verify files from web3.storage
const res = await client.get(rootCid) // Promise<Web3Response | null>
const files = await res.files() // Promise<Web3File[]>

for (const file of files) {
  console.log(`${file.cid} ${file.name} ${file.size}`)
}

Mutability

Management of mutable name records with IPNS has now moved to the w3name client.

Testing

Run npm test to test the ESM code, CJS, and in the browser via playwright-test. 100% test coverage is required by the hundreds module.

To test in individual environments, you'll need two terminal windows open. In the first, start up the mock API by running npm run mock:api. In the second, you can then run npm run test:web, npm run test:esm or npm run test:cjs.

Tests are written in mocha and use a mock API server to assert functionality. When adding a new method to the client, add a test/<method>.spec.js test suite to go with it.

The mock api is built with smoke file-based mock server. You add a files to the test/mocks/api directory, and the file name determines which API enpoint you are mocking. You can provide a .json for a static response, or a .js file to add some logic to the mock.

  • post_car.js handles POST /car requests.
  • get_car#@cid.js handes GET /car/:cid requests. The cid part of the path is provided to the mock as params.cid.

Add more mocks as required.

web3stash-testlorem-computerblockstor-testweb3store-test@infinitebrahmanuniverse/nolb-web3xmtp-react-widgets@everything-registry/sub-chunk-3125@_koii/k2-nodegetipfscidgitsolgaia-clientgaia-toolsgelato-snapgelato-gasless-snapelefria-beta-sdkexplorerxezyfileinfinitymintinfinitymint-btinfinitymint-clientlinearprotocolipfs-freeipfs-encryptedipfs-scriptsipfs-storagenephw-sdkmigrate-to-w3upmini-daos-sdknj_dmvoncohub-web3-storagepicgo-plugin-web3-storagemessenger-widgetmerlin-web3-enginemyweb3fsmultiwebsdk-airdropunidata.js-altersandeshselfguard-nodesupercuteworld-ipfssuperhelper-clistrapi-provider-upload-web3-storagestorliweb3-importerweb3-storage-cliweb3-storeweb3.storage-lit-sdksadaivsentre-web3weloweb3stash-test1web3storage-hooksweb4-deployweb3stashzk-trace-sdkwhitelabel-kit@_koii/create-task-cli@_koii/k2-recipient-sdk@aletheia-data/strapi-provider-upload-web3-storage@aragon/osx-cli@andrewtheguy/web3storage@aragon/clidaoscord@dm3-org/dm3-messenger-widget@dapplet/cli@dapplet/shell@web3-storage/w3@windingtree/lpms-server@zaifer/nuxt-web3kit@unstoppabledomains/ui-componentsanimietaws-snapshots@tabcat/zzzyncbfast-database-corebisp-backend-jim@fungyproof/storage@glif/deployment-cli@gordo-d/web3storage-hooksdearwebthreecupiditateveldelenitiquicrossxcrossx-cli@cardstack/hubdm-widgetdm3-lib-deliverydm3-lib-profiledm3-messenger-widgetdm3-reactdm-pack@fazio/ipfs-upload-button@hypercerts-org/hypercerts-sdk@ngx-web3/sdk@opendreamnet/deploy@js-ligo/agreements@meteor-web3/utils@meteor-web3/components@sen-use/app@sen-use/web3citizenprotocol
4.5.5

10 months ago

4.5.4

1 year ago

4.4.0

2 years ago

4.3.0

2 years ago

3.5.7

2 years ago

4.1.0

2 years ago

4.0.0

2 years ago

4.2.0

2 years ago

3.5.6

2 years ago

3.5.3

2 years ago

3.5.2

2 years ago

3.5.1

2 years ago

3.5.5

2 years ago

3.5.4

2 years ago

3.4.0

2 years ago

3.3.4

2 years ago

3.5.0

2 years ago

3.3.3

3 years ago

3.3.2

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago