How to deal with forms,images,videos of an asset in hyperledger composer

别说谁变了你拦得住时间么 提交于 2019-12-30 07:45:08

问题


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.]


回答1:


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://www.thepolyglotdeveloper.com/2016/02/convert-an-uploaded-image-to-a-base64-string-in-node-js/

-> https://belltane.wordpress.com/2017/03/27/storing-images-in-hyperledger-fabric-blockchain/



来源:https://stackoverflow.com/questions/47751609/how-to-deal-with-forms-images-videos-of-an-asset-in-hyperledger-composer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!