I am currently working on a project in Hyperledger, where I want to upload files like pdf and docs into hyperledger blockchain by distributing the document file across the node of the network, and retrieving the document file back. Please help me with how I can do and how should I approves. If it cannot be achieved in Hyperledger then please let me know by which blockchain it can be achieved. Thanks in advance.
-
Does this answer your question? [How to upload image on hyperledger composer playground?](https://stackoverflow.com/questions/54872377/how-to-upload-image-on-hyperledger-composer-playground) – Isha Padalia Jan 17 '20 at 08:51
-
@IshaPadalia No it does not answer the question – Karthik C Yadav Jan 17 '20 at 12:07
-
@karthikyadav Finally, is it possible to upload docs on hyperledger fabric without an external storage system such as IPFS? – HectorCode Sep 08 '20 at 11:56
3 Answers
As a general rule, blockchain technologies are not suitable to store large documents. Blockchain demands too much process and storage replication. Moreover, there are some more pitfalls, such as block size and confidentiality.
One common approach is storing the files in a distributed P2P storage system such as IPFS (https://ipfs.io/) and store the file's hash (hashes are used as file references in IPFS, so that integrity is assured) in the blockchain's state.
You may need also IPFS-Cluster (https://cluster.ipfs.io/) to ensure persistence and replication.
Encryption is not supported by IPFS, so, if needed, it should be applied end to end outside IPFS, encrypting before storing and decrypting after accessing.

- 2,179
- 11
- 12
-
Yes, I know that blockchain is not meant to store larger files, but in hyperledger fabric, we can configure the block size, consensus, etc.., I have done storing the files in IPFS and storing the hash in Ethereum blockchain. But I taught I can store the files in Hyperledger is it possible. Correct me if I am wrong. Thanks – Karthik C Yadav Jan 17 '20 at 12:14
From your comment it sounds like you are thinking of using Hyperledger Fabric. With Fabric you should be able to write chaincode and a client that stores files. It still might not be the best approach and you should think carefully about separating storage of large files from the blockchain consensus based chaincode, especially when storing a hash of the file on-chain would suffice. Each node will need to store the file and come to consensus that all nodes stored the same file (have the same state). This is expensive in terms of compute and network i/o.
With Fabric, you should be able to do just about anything in code, as long as it is deterministic and not a long-running process. In my experience, minimizing code and state on any blockchain is best practice.
A complete example of a Hyperledger Fabric implementation is here: https://fabric-chaintool.readthedocs.io/en/latest/getting-started/

- 231
- 2
- 5
-
Is it possible to achieve this? Like when a file is uploaded then it divided into pieces and store it blockchain network like decentralized distributed storage. So that if one server goes down then the file can be accessed by other servers. – Karthik C Yadav Jan 18 '20 at 06:21
I agree with Kekomal, don't put large files in a blockchain, as it bloats it. Rather store binary/large files offchain. One option in Hyperledger Fabric(HLF) are private data collections where you can store binary files in CouchDB as base64 text, and just store the checksum/hash onchain, but that would increase storage requirements - based on base64.guru a 20KB pdf in base64 text will be 26KB - probably significant with very large binary files, as well as improper use of a document db. Private data collections are nice as HLF let's you share files with various options

- 91
- 1
- 1
- 4