While defining an asset in hyperledger composer model file, how do we deal with forms, images, videos? What are the data types available? For example, if my asset is house and I want to store an image of the house how do I define this in an asset?
I have referred the documentation, it says the primitive data types available are string, integer, double, DateTime and boolean.]
Asked
Active
Viewed 1,605 times
1

Sneha
- 147
- 7
1 Answers
2
So technically, this is a Node question. Using Javascript, eg. fs.readFileSync(‘yourimageFile.jpg’).toString(‘base64’);, you should be able to convert the image to a Base64 string in your code.
So you can define 'String' for your chosen (modeled Asset type etc) field to host in Hyperledger Composer. The theory is that, once it is a string, it is sent to the chaincode just like any other string.
these links may help:
-> https://belltane.wordpress.com/2017/03/27/storing-images-in-hyperledger-fabric-blockchain/

Paul O'Mahony
- 6,740
- 1
- 10
- 15
-
1For posterity's sake: normally, 'best practise' is not to store images etc on the blockchain, but maybe a hash of the media/file and a reference to how/where its stored off-chain – Paul O'Mahony Dec 11 '17 at 12:37