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

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

问题描述

在 hyperledger composer 模型文件中定义资产时,我们如何处理表单、图像、视频?有哪些可用的数据类型?例如,如果我的资产是房子并且我想存储房子的图像,我如何在资产中定义它?
我参考了文档,它说可用的原始数据类型是字符串、整数、双精度、日期时间和布尔值.]

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://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/

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

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