Created
November 15, 2015 06:13
-
-
Save tako2/421a3df53f1a855ecdb0 to your computer and use it in GitHub Desktop.
node.js script for getting image file from THETA S.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request'); | |
var fs = require('fs'); | |
if (process.argv.length < 3) { | |
console.log('node get_image.js [Filename]'); | |
console.log("\tFilename: Image Filename such as R0010010.JPG"); | |
return; | |
} | |
var file_uri = process.argv[2]; | |
console.log('Get Image from "100RICOH/%s"', file_uri); | |
var options = { | |
uri: 'http://192.168.1.1/osc/commands/execute', | |
headers: { 'Content-Type': 'application/json' }, | |
json: true, | |
keepAlive: false, | |
encoding: null, // IMPORTANT | |
body: { "name": "camera.getImage", | |
"parameters": { "fileUri": "100RICOH/" + file_uri } | |
} | |
}; | |
request.post(options, function(err, res, body) { | |
if (err) { | |
console.log(err); | |
return; | |
} | |
if (res.statusCode == 200) { | |
// console.log(res.headers); | |
console.log('Save Image to %s', file_uri); | |
fs.writeFile(file_uri, body, encoding="binary"); | |
} else { | |
console.log('Connection Failure... (%d)', res.statusCode); | |
// console.log(body); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment