Uploading file to Safe network

@Krishna_Kumar Just wanna know if we can use any other way to upload files to network without safeMutableDataEntries.insert. If YES… Can you just help me on that?? Tq.

I mean I just need an idea. Would be really great.

1 Like

File is just a binary data. You can create your own structures/toplogy for storing files. For example, a simple JSON representation like,

  name: "sample.txt",
  createdOn: utcDateString,
  modifiedOn: utcDateString, 
  content: Address of DataMap - Uint8Array

For this you can use the ImmutableData API to write the file content into the network and get the address of the Datamap. You can create a JSON structure like that to hold the metadata and the content of the file.

However, this JSON structure has to be stored somewhere to fetch it again. That is why we need the MutableData to hold the values in a deterministic address or default containers or in app’s root directory to fetch again.

If you choose not to save this info in the network for some reason, you can base64/hex encode the json data to save it locally or generate a QR code which can be saved by the user (like the paper wallet! I am just being crazy :wink:). It all depends on what the app is intending to do.

I would advise that the apps should not leave any local trace on the user’s machine.


Dev fourm would be the best place for API related questions.

1 Like

This topic was automatically closed after 60 days. New replies are no longer allowed.