How to upload mutiple file same in a folder

i’m using Kubo RPC /api/v0/add for upload file to ipfs. Currently, I want to be able to upload many files in the same folder to ipfs. I intend to use wrap-with-directory or name the folder the same, but when I push each file, they are all in different folders that I cannot control.

1 Like

You may want to try using the Mutable File System MFS to create directories and add files.

See the Kubo RPC API methods under /files, e.g. Kubo RPC API | IPFS Docs

I suppose that you need to upload them in separate /add requests, as otherwise you could upload them all in the same /add request and wrap-with-directory should work. But if you need multiple requests, you can add them first and then move them to the right mutable folder with the MFS operations.


Here’s how I do it with Python and the Kubo RPC API. No MFS (I’d never even heard of it)

The pertinent bit for constructing the ‘folder’ of files is lines 37 through 50, but note how some of the attributes need to be worked out in advance Lines 17 through 30), such as the size in bytes, etc.

You could probably make it a loop to be more efficient, I just wanted to make the PoC very explicit as to what is happening.

1 Like

Thank you , my problem has been solved.

1 Like