Adding file into a stream

+1 vote
Hello,

in the Getting Started documentation it is mentionend that you can pipe random data directly to the cache via its file when you are using Linux. Is this also possible when using Windows? If so how can this be realized?

I just want to try to add a pdf and XML-File into the binary cache respectively into a stream.

Thank you in advance.
asked Feb 4, 2019 by nobody

1 Answer

+1 vote
 
Best answer

Yes, you can absolutely do the same thing in the Windows – copy and data you want into the appropriate file in the same cache directory, and then publish the file from there. On Windows the cache file is here:

%APPDATA%\MultiChain\[chain-name]\cache\[cache-item-name]

answered Feb 4, 2019 by MultiChain
selected Feb 8, 2019 by nobody
Hello,

thank you for your help.

I'm just not sure if I got this right:

I copied the files in my cache directory (in my case a PDF- and an XML-File).

In the Getting Started documentation I found this command:

appendbinarycache [binary identifier] ...

How exactly can I append my files to the binary cache and how can I publish them?  Does it mean I need mandatorily the hexadecimal representation of the files? If so how do I get that representation?

Does the following command mean that the whole binary cache (including its files) is published?

publish [streamname] key1 "{\"cache\":\"[binary identifier]\"}" offchain

Thank you in advance.
1. Create a cache item using the createbinarycache command.
2. Copy your file contents to the cache item's file via the file system.
3. Publish using the publish command you showed, including the cache item identifier.
4. Use deletebinarycache to remove the item when you're done.
Hello,

thank you for advice.

It worked so far when I copied my file content to the cache item's file.

It also worked when I transfered an XML-File via appendbinarycache in hexadecimal format to the cache item's file.

Then I also converted a PDF-file into hexadecimal format and tried to append it via the appendbinarycache command to the cache item's file as well.

But I got an error message since only one part of the hexcode could be pasted into the (Windows-) DOS-Commandline. I guess this happens due to the limitation of the amount of characters (8.191 characters in our case for Windows Server 2012) which can be pasted into DOS.

So I have the following questions:

1. When I paste the hexcode directly into the cache items file would the cache item file be able to process the data as well or is it necessary that the cache item file only contains plain text?

2. Alternatively is there another way to transfer a PDF-File (as hexcode) into the binary cache without having to develop an extra application for it?

Thank you in advance.
1. The data you copy into the cache item file should be the raw data (whether text or whatever else), not its hexadecimal representation.

2. You can call appendbinarycache any number of times, to build up the content of the cache file a few KB at a time.

But really your simplest solution is just to copy the file in directly via DOS.
...