upload file to multichain

+1 vote
I am trying to understand streams and looking into file storage using multichain. I found an online tutorial - https://blog.cotten.io/streams-and-multichain-3890d7da3415 and in the example they save the file contents and not the file itself.

When uploading the stream I know it requires a hex value as a string. But is this value meant to be the file or the file contents? I would ideally want to be able to upload a file, in any format, and then be able to retrieve the file in the same format.

Could you please provide an example/information of how I can achieve adding a txt file to the blockchain and then being able to view and download it.
asked Jul 9, 2017 by doldy101

1 Answer

0 votes

The answer is the file content in its entirety, plus some extra information (like the file name) if you want it. You can see an example of this in the MultiChain Web Demo, which uses hexadecimal 00 (zero bytes) to delimit between the file name, MIME type, and finally the file content itself. See the file_to_txout_bin()function used in page-publish.php and defined in functions.php: https://github.com/MultiChain/multichain-web-demo

answered Jul 9, 2017 by MultiChain
Thanks for the information.
Would I be right in saying that when a user goes to retrieve a file from the blockchain that file will have to be recreated on the backend before it gets to the user?
I am 99% sure it does have to be recreated because of the way it's stored, but would like some confirmation
Yes, the hexadecimal should be extracted via the API and then converted back into a file at the time of retrieval.
...