Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add attachments to blockchain payload #35

Open
mna2016 opened this issue Jul 10, 2017 · 4 comments
Open

How to add attachments to blockchain payload #35

mna2016 opened this issue Jul 10, 2017 · 4 comments

Comments

@mna2016
Copy link

mna2016 commented Jul 10, 2017

I would like my use case to have the ability to have PDF documents present in the blockchain payload.
How to achieve this?

Appreciate an early response. Many Thanks.

@kletkeman
Copy link
Contributor

There are several ways of handling documents on the blockchain. If the documents (and I mean that generically, PDF, MP3, WAV, MP4 and so on) are large, then it is likely that the documents should remain remote and that the smart contract should be working with the documents' identities (URL plus Hash). This has pitfalls of course, in that the hash should be calculated by the contract but there is some complexity involved with making that deterministic (so that all endorsers calculate the same responses). Using an external hash calculation can work as well, but introduces the need to trust the system that calculates the has of the document as much as the blockchain is trusted.

The second method for smaller documents is to embed a complete into a transaction that stores it in world state. The document should be compressed and then encoded to a textual format (e.g. base64). But you would have to test this pretty thoroughly to see how well the v1 fabric handles bulk data into world state.

@mna2016
Copy link
Author

mna2016 commented Jul 11, 2017

@kletkeman Thanks for the very early response!
I have done as instructed. Application frontend is converting PDF into base64 format. I am now working on compression to make the base64 string even smaller(if that is possible).
The possible size of document I am looking at is a 1 page pdf document with a few small images. Something that generally takes between 200 to 500KB. I am yet to test whether the blockchain payload allows this much data in a transaction.

@kletkeman
Copy link
Contributor

Let me know how you get along on that score. 500KB might be a bit much, but time will tell. You only need to write that once per doc to the database, after that you can simply update its metadata as needed.

@mna2016
Copy link
Author

mna2016 commented Jul 18, 2017

I have tested successfully posting 650KB of uncompressed base64 string(the pdf document) in the blockchain payload. It worked! I think the actual document will be <250KB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants