Skip to content

Instantly share code, notes, and snippets.

@melvincarvalho
Created June 6, 2014 11:13
Show Gist options
  • Save melvincarvalho/f87940fedcc43bcd98f9 to your computer and use it in GitHub Desktop.
Save melvincarvalho/f87940fedcc43bcd98f9 to your computer and use it in GitHub Desktop.
PUT a file to a data space
var https = require('https');
var fs = require("fs");
var options = {
host: 'domain_name',
port: 443,
path: 'path_to_file',
method: 'PUT',
key: fs.readFileSync("path_to_key.key"),
cert: fs.readFileSync("path_to_cert.crt"),
headers: { 'content-type': 'text/turtle' }
};
var req = https.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
});
req.write('<> <> <> .');
req.end();
req.on('error', function(e) {
console.error(e);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment