Update content on IPFS

Hi there,

I am working on an app that allows users to share files with their friends. I use orbitdb to store IPNS hashes for mutability. The access control works with asymetric encryption and every “file” has the following structure

-> this file is encrypted with symetric encryption

-> those files contain the symetric key encrypted with the public key of every device that can read the file

-> those files contain the ipns private key encrypted with the public key of every device that can write to the file

I have no problem adding this to ipfs, but I have a concern on how to update a file.

There are 2 basic scenarios of updates:

  1. The file itself changes, this means updating the /data file, since the keys can stay the same
  2. Giving a user the ability to read/write to the file, where there is a new key added to one of the key directories /dataKeys/some-new-hash or /ipnsKeys/some-new-hash

Lets take example 2: How can I add a new key without uploading all other keys and the data file again? (Thats the main question, because with large files or many keys this will take a while and even consume a lot of data if you are on mobile)

I know that the ipfs hash changes due to how the content addressable web works, thats why I use IPNS to store the new hash after each update.

Right now I use ipfs.add to upload the file and I read the docs about the mutable file system, but the write/rm/… methods seam only to work with paths like /some/path/… and not with ipfs hashes.

I hope someone can help me clean up my confusion :slight_smile:


Hi Totem,
I have the same issue here, if you have a solution in the meantime let me know plz…
What I understand about it till now is that the files-api (MFS) can be used if you want to assemble (and in this process of assembly you can rename or remove or move your files etc.) a file-stucture. When you are done you can get the CIDhash with ipfs.files.stat. (you can get the hash so easily because the files-api (MFS) is connected to the (regular) files-api, so what is saved in MFS is also put on IPFS automatically).
If you want to change something later, this is not easy/possible. I would think you have to first fetch the files from IPFS to put them in MFS (I didn’t figure out how that is possible (I have tried .read .cat and .get and they all do not save the files in the MFS “sandbox”)

The object-api can be used to make a data-structure (dag IPLD). In the structure you can put nodes containing property values and/or links to another node. I understand there is a 4mb size limit to files you ad with a buffer (I got this answer from Volker last time). Maybe we can get around this by creating a separate file cid first, and then ad it to the data-structure. Never mind… with the object.patch.setData you can update your property values and get a the hash back without having to download the whole data-structure.

I hope this can help anyone :slight_smile:

Hi @RenaPero, i’m also facing the same issue if you have solution for that please let me know.

Hi prag,
I am working it now (already for quite some time now :hear_no_evil:), but what I am going to do with this:
Information or properties or text (however you want to call it) is saved in an IPLD dag with .object-api , traversable by a path. Since it is not really possible to store reasonable sized files in IPLD, I came-up with the solution to just store (in the IPLD dag) the hash of the file as plain information (so not as link). This way the file becomes traversable by path :eyes:
To get the hash of the file you need to ad it first of course with .add or MFS .files-api and use .stats
I hope this can help you!