Hyperledger composer document attachment support

create bna file composer
hyperledger composer architecture
hyperledger composer playground tutorial
hyperledger composer tutorial pdf
hyperledger bnd file
how to start hyperledger composer
hyperledger composer vs chaincode
hyperledger composer vs fabric

Does hyperledger composer support document (.doc, PDF, or an image) attachment? Basically, I want to add a document as a property of an asset in the model file. I'm a beginner, any advice will be appreciated!

It is advisable not to put huge files into the blockchain. Therefore what you can do is store it somewhere and store the link to one path variable. To make sure the file isnot altered, you can hash the contents of the file while storing it somewhere and check the hash while retrieving it. In case you need to store the files in blockchain being mandatory, you can encode files to base64(recommended) string and decode it to get the file again.

Hyperledger composer document attachment support, Does hyperledger composer support document (.doc, PDF, or an image) attachment? Basically, I want to add a document as a property of an asset in the model� Welcome to Hyperledger Composer Hyperledger Composer is an extensive, open development toolset and framework to make developing blockchain applications easier. Our primary goal is to accelerate time to value, and make it easier to integrate your blockchain applications with the existing business systems.

You can store your file data into the IPFS. IPFS is a protocol and network designed to create a content-addressable, peer-to-peer method of storing and sharing hypermedia in a distributed file system.

For IPFS I recommend you to follow the link.

IPFS will give you a Hash link after successfully upload a file. You can store that hash into an asset or participate of hyperledger composer.

I hope it will help you :)

Modeling Language, Support. API Reference. API Class Index � AdminConnection (Admin API) Hyperledger Composer includes an object-oriented modeling language that is used to define the A Hyperledger Composer CTO file is composed of the following elements: Resources and properties of resources may have decorators attached. Hyperledger Composer is a set of open source tools that allows various business owners, operators, and developers a way to create blockchain applications and smart contracts aimed at solving

Lets assume you mean a PDF file. And there is a simple Asset called Invoice

Asset Invoice identified by id {
  o String id
  o String pdfLocation
  o String pdfHash
}

Now you could technically define an array and store the pdf as a string but as mentioned, it is not a good practice. Instead in one of my PoCs I have implemented a solution as follows.

  1. First step is a user creates a new Invoice asset and along with it wants to attach a pdf copy of the actual invoice
  2. He sends an API call with the details and uses multer to parse the PDF. This returns the info in req.file which is then handled using express and stored in mongoDB
  3. Once the file has been stored in mongoDB, it can only be accessed by a direct API call to the server. Whatever ACL you want to apply, you do it here in the middleware
  4. Once the document is stored, mongoDB or any other db will return a primary key. This is stored in pdfLocation. When the invoice wants to be retrieved, the user will first get the Invoice asset, access the pdfLocation and then query the document from mongoDB itself by referencing the primary key

Quick snippets to get you started

const express = require('express');
const multer = require('multer');
const router = express.Router();
let storage = multer.memoryStorage();
let upload = multer({ storage: storage })

router.post('/invoice, upload.single('invoice-pdf'), createInvoice);

const createInvoice = async (req, res, next) => {
  // Do your usual stuff of connecting via businessNetworkConnection
  // Assume the file upload is a success

  let document = new documentSchema({
        originalName: req.file.originalname,
        file: req.file.buffer,
        creationDate: new Date()
       );
  let param = await document.save();
  primarykey = param._id;

  let newInvoice = factory.newResource(BASE_NS, 'Invoice', req.body.id);
  // Add whatever values you want
  newInvoice.pdfLocation = primaryKey;
  await registry.add(newInvoice);
}

Document schema is a simple collection to store the info. Looks like this

const documentSchema = new Schema({
  originalName: {
    type: String,
    required: true,
    unique: true
  },
  file: {
    type: Buffer,
    required: true
  },
  creationDate: {
    type: String,
    required: true
  },
});

Assume you can do something similar if you use a different database Now the user wants to retrieve the same PDF file from the invoice. End result, he calls an API from the frontend and is given a PDF he can download

router.get('/invoice/pdf', someSecretACL, getPdfFile);

const getPdfFile = async (req, res, next) => {
  // Connect to the business network, load the registry

  let invoice = await registry.get(req.body.id) // Get the invoice
  let primaryKey = invoice.pdfLocation;

  // Now get the bytes from mongoDB and send them to the browser
  let array = await documentSchema.find({ _id: id });
  let pdf = array[0] // assume successful call
  res.contentType("application/pdf");
  res.send(pdf .file);
};

const someSecretACL = async (req, res, next) => { // Do some checks here };

Getting support, Because IBM does not support using Hyperledger Composer for production implementation, you Attach any relevant logs or files to demonstrate your issue. Composer is a user-facing rapid prototyping tooling, running on top of Hyperledger Fabric, which allows the easy management of Assets (data stored on the blockchain), Participants (identity management, or member services) and Transactions (Chaincode, a.k.a. Smart Contracts, which operate on Assets on the behalf of a Participant).

[BE-259] Create instructions "How to configure Hyperledger Explorer , Description. We have many requests to help on configuring Hyperledger Explorer with Hyperledger Composer , see rocket chat, link: Attachments. Install Hyperledger Fabric & Composer.doc: 94 kB: 11/Jul/18 1:03 PM. Hyperledger Fabric | Composer Framework. Hyperledger Fabric is a "Distributed Ledger Technology" a.k.a. Blockchain technology that has been built ground up with the needs of the "Business Blockchain Applications" in mind. Composer is a development framework that accelerates the development of Business Blockchain applications of Fabric platform.

Hyperledger Composer – Hyperledger, None of the maintainers are actively providing support via GitHub issues. Hyperledger Composer is a set of collaboration tools for building blockchain business networks that make it simple and fast for Read the Composer Documentation. However, Composer has been designed so that it can be ported to run on other distributed ledger technologies, such as Hyperledger Iroha or Hyperledger Sawtooth. Why? All “blockchain business networks” share certain elements – namely assets, participants, identities, transactions, and registries.

How can I add image into my Hyperledger instance, In your modeled Asset in Hyperledger Composer, one attribute for 'imageString' is defined as 'String in your Hyperledger Composer model file. Hyperledger Composer Historian The Hyperledger Composer Historian is a specialised registry which records successful transactions, including the participants and identities that submitted them. The historian stores transactions as HistorianRecord assets, which are defined in the Hyperledger Composer system namespace.

Comments
  • using IPFS, as long as anyone has the hash provided from IPFS, they can retrieve the doc from IPFS. I don't want to happen that. How do I secure the doc from an authorized access? Thanks for your suggestion.