import { Web3Storage } from 'web3.storage'const client = new Web3Storage({ token: apiToken })

Store files#

Store files using the put() method.

<clientObject>.put(file[], { options })

Examples#

In the browser, using a file chooser to prompt the user for files to store:

const fileInput = document.querySelector('input[type="file"]')const rootCid = await client.put(fileInput.files, {  name: 'cat pics',

Return value#

The method returns a string containing the CID of the uploaded CAR.

Parameters#

Method parameters are supplied in positional order.

Untitled

An {options} object has the following properties that can be used as parameters when calling put():

Retrieve files#

Retrieve files using the get() method. You will need the CID you obtained at upload time that references the CAR for your uploaded files.

Example#

Return value#

Returns undefined if there are no matches for the given CID.

If found, the method returns a Web3Response object, which extends the Fetch API response object to add two iterator methods unique to the Web3.Storage client library: files() and unixFsIterator().