- ipfs or storj
- hash of image and store file on s3
- convert the image to a Base64 string and store string in composer model
问题:
回答1:
You can use String and base64 encode it - as a field in an Asset for example.
The question has been discussed here: How can I convert MP3 file to a Base64 encoded string? and here: How to deal with forms,images,videos of an asset in hyperledger composer .
Storing images, scans, audio files is not a 'best practice' - rather, a cryptographic hash of it (referenced off-chain) is verifiable proof that the source is the exact image/media file that was 'hashed' at the time the 'transaction' was recorded on the blockchain and link out of the chain, to a URL containing the verifiable source (and comparable hash). Examples may be: doctor/patient audio discussions (not least the privacy elements!) & consultation recordings, PDFs, mp3s, image files. Another issue is that an encoded base64 image string (if you chose to encode the media/image file that is) will also need to be transmitted to the other peers participating in consensus and written to their copy of the master ledger. It is therefore more efficient, to only share the hash (not the base64 encoded contents with each peer).
回答2:
Sahil, you need not store an encrypted file in blockchain. One solution is (for keeping privacy of your data) to store the hash of your file in an asset field. The encryption of the same data will sit outside the blockchain, so your have to create one asset field containing the link to that encrypted file.