How to getFile or putFile from blockstack CLI?


#1

i installed the blockstack via pip and noticed that there are getFile and putFile functionality there as well as blockstack.js but i can’t find the required field t successfully get or put a file.

can you recommend a tutorial that use CLI to upload and download files or how I can find the datastore id and other parameters that are required by this command?

Thanks.


Putting files from backend
#2

@mhadiemami our storage tutorial illustrates some examples of getFile() and putFile().

Our CLI is undergoing some revamping. @jude may have an some suggestions for what you ask.


#3

thank you @moxiegirl for your reply. i already created an app that uses blockstack.js to put and get files but i need to do the same function from nodeJs server (without any browser).


#4

This is not an officially support method as far as I know, but with the authResponseToken and identityAddress, here’s a code snippet that will work in Node:

var request = require("request");

var options = { method: 'POST',
  url: 'https://hub.blockstack.org/store/' + identityAddress + filename,
  headers: 
 { 
 Authorization: 'bearer v1:' + authResponseToken,
 'Content-Type': 'application/octet-stream' },
  body: '{\n\t"title": "Test"\n}' 
  };

request(options, function (error, response, body) {
if (error) throw new Error(error);

console.log(body);
});

#5

You can do it with the CLI. Type blockstack-cli help gaia_getfile or blockstack-cli help gaia_putfile to see usage and examples.