Offchain storage of files

+2 votes
Hi,

How can we add a file to the offchain and the process to retrieve the original file from another node.

Do we need to convert the file to Hex format and append it using append binarycache. (Im getting error is Hex value of file is large as "Data should be hexadecimal string")

Or we can just copy the file contents to the cache file as mentioned in below link. (In this case file is in raw format and not binary)

https://www.multichain.com/qa/12710/adding-file-into-a-stream

Any detailed steps would be helpful to every users.

Thanks.
asked Mar 19, 2019 by blkchain_enthu

1 Answer

+1 vote

Yes, you can copy the file directly to the input cache using the file system and then publish it in a stream item using this kind of parameter form:

{"for":"stream1","keys":["key1","key2"],"data"{"cache":"Ev1HQV1aUCY"}}

See also the txouttobinarycache command in the latest 2.0 beta which allows large pieces of data from the blockchain to be dumped into the binary cache. Once there they can also be read via the file system.

answered Mar 19, 2019 by MultiChain
How can I retrieve the file back from Binary cache..Is it with any API's?

also while converting the file to Hex format and append it using append binarycache as mentioned,
I'm getting error is Hex value of file is large as "Data should be hexadecimal string"

How to handle this..I dont want to copy te file contents directly to cache since i see its not encrypted and its in raw format.!!
You can access the binary cache directly as a file in your disk. Each binary cache item is stored as a file in the cache subdirectory of the blockchain directory.

You can remove a file from the binary cache as soon as it's put in the blockchain, so its encryption should not concern you. In any event the data on the blockchain itself is not encrypted unless you encrypted it yourself.
...