Reputation: 701
In model file, We have have 'string' data type to store any string. However; If I would like to store file into hyperledger fabric using hyperledger composer, then is there any specific data type?
Upvotes: 0
Views: 1066
Reputation: 8213
According to the reference here, the string
type contains UTF-8 encoded character sequences. Therefore, you cannot just put the bytes of a file into a string
.
One of the possible solution is encoding the file into a base64 (uudncode
, base64encode
, etc.) string first, and then store it in a string
field.
Based on your requirements (personal data regulations, etc.), you may want to store the file off-chain, and store only the cryptographic hash (SHA-1, SHA-256, etc.) of the file in the chain (as a string
).
Upvotes: 3