How to upload multiple files on IPFS under the same CID with cURL

Hello everybody,

If you’d like to add multiple files to IPFS under a CID that wraps them all together, please see the below example request.
In order to do so, use the “wrap-with-directory” parameter and set it equal to “true”. Add multiple files, with their full path, to your request by specifying as many -F options.
Don’t forget to set the “pin” parameter equal to true if you’d like to pin the CID of the directory object to your Infura IPFS project, and to use your Project ID and Project Secret when authenticating the request.

curl "" \
        -X POST \
        -u "Project Id:API KEY SECRET" \
        -H "Content-Type: multipart/form-data" \
        -F file=@"/home/user/ipfs_files/picture1.JPG" -F file=@"/home/user/ipfs_files/picture2.JPG" -F file=@"/home/user/ipfs_files/picture3.JPG"

The request outputs the CID of each of the files and the CID of the directory object that wraps them together, as per the below.


As mentioned earlier, only the CID of the directory object will be pinned to your Infura IPFS project. To list the files under the directory you can use the Infura public gateway or your own dedicated gateway.

Also through our community we have learned of a useful solution when you have a bunch of files and don’t want add them manually to your request:

cd /your/chosen/path
FILES=$(find * -type f | grep -v ' ' | sed -e 's/ /\\ /g' | awk -v q="'" '{print " -F " q "file=@\"" $0 "\"" q}')
curl "" -X POST -H "Content-Type: multipart/form-data" $FILES

Do you by any change, have a working example to add a full directory in node.js using ipfs-http-client

1 Like

Hey Arif, welcome to the community.

Please see the below article:

and the code example below:

const { globSource, create} = require('ipfs-http-client')
const projectId = '27xxxsj';
const projectSecret = '20xxx5b';

async function addFolder(){
  const auth =
    'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64')
    const client =  create({

        host: '',
        port: 5001,
        protocol: 'https',
        headers: {
          authorization: auth

    for await (const file of client.addAll(globSource('/home/user/path/to/directory', '**/*'))) {