Skip to content

Instantly share code, notes, and snippets.

@bonedaddy
Created December 22, 2019 05:24
Show Gist options
  • Save bonedaddy/0c61cab52bd5f2e07e4e0504669aef48 to your computer and use it in GitHub Desktop.
Save bonedaddy/0c61cab52bd5f2e07e4e0504669aef48 to your computer and use it in GitHub Desktop.
var grpc = require("grpc");;
var fileService = require("./file_grpc_pb");
var fileMessages = require("./file_pb");
var dotenv = require("dotenv");
var fs = require("fs");
/*
var grpc = require("grpc");
// dag grpc imports
var dagMessages = require("./dag_pb");
var dag_grpc_pb_1 = require("./dag_grpc_pb");
// pubsub grpc imports
var pubMessages = require("./pubsub_pb");
var pubsub_grpc_pb_1 = require("./pubsub_grpc_pb");
*/
dotenv.config();
// setup
const host = process.env.TEMPORALX_HOST;
const credentials = grpc.credentials.createSsl();
const options = {};
console.log(`Using host ${host}`);
const fileClient = new fileService.FileAPIClient(host, credentials, options);
// get a file
const downloadRequest = new fileMessages.DownloadRequest();
downloadRequest.setHash('QmU53H1GxHDYFhq97yenFL3m8WBoehHARkw3TYMw8QTGzz')
const downloadResponse = fileClient.downloadFile(downloadRequest);
downloadResponse.on('data', console.log);
downloadResponse.read();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment