0

I am using Web3 Storage in order to upload my data to IPFS. The link always ends up being ipfs://CID/1.png instead of ipfs://CID.

This is my code:

import { Web3Storage, getFilesFromPath, CIDString } from 'web3.storage'

const files = await getFilesFromPath(`./outcome/1.png`)
const cid = await client?.put(files)
console.log(cid) //this returns only CID as it should, but the URL to access that data is different

Can I save the data under the CID without having to go to another file under it? What should be the correct code?

1 Answer 1

0

This slight change fixes it, more in docs.

import { Web3Storage, getFilesFromPath, CIDString } from 'web3.storage'

const files = await getFilesFromPath(`./outcome/1.png`)
const cid = await client?.put(files, {
        wrapWithDirectory: false
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.