如何在Hyperledger Composer中处理资产的形式,图像,视频 [英] How to deal with forms,images,videos of an asset in hyperledger composer

查看:86
本文介绍了如何在Hyperledger Composer中处理资产的形式,图像,视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Hyperledger Composer模型文件中定义资产时,我们如何处理表格,图像,视频?有哪些可用的数据类型?例如,如果我的资产是房屋,并且我想存储房屋的图像,该如何在资产中定义它?
我已经看过文档,它说可用的原始数据类型是字符串,整数,双精度型,DateTime和布尔型.]

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

推荐答案

从技术上讲,这是一个Node问题.使用Javascript,例如fs.readFileSync('yourimageFile.jpg').toString('base64');,您应该可以在代码中将图片转换为Base64字符串.

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.

因此,您可以为所选(建模资产类型等)字段定义字符串",以托管在Hyperledger Composer中.从理论上讲,一旦它是一个字符串,便像其他字符串一样被发送到链码.

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/

这篇关于如何在Hyperledger Composer中处理资产的形式,图像,视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆