Last active
August 29, 2015 14:26
-
-
Save karl-gustav/4e6933a2d5abc71c548a to your computer and use it in GitHub Desktop.
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
'use strict'; | |
var fs = require('fs'), | |
request = require('request'), | |
crypto = require('crypto'), | |
filePath = process.argv[2], | |
translationBlueprints = fs.readFileSync(filePath), | |
hash = crypto.createHash('md5').update(translationBlueprints).digest('hex'), | |
//server = 'http://translations.fronter.net/zanata', // 3.4.2 | |
server = 'http://translations03.dub1.fronter.net/zanata', // 3.7.1 | |
url = server + '/rest/file/source/login-service/master?docId=blueprints', | |
formData = { | |
hash: hash, | |
first: 'true', | |
last: 'true', | |
type: 'GETTEXT', | |
file: translationBlueprints | |
}, | |
headers = { | |
'X-Auth-User': 'not-real-user', | |
'X-Auth-Token': 'not-real-key' | |
}; | |
request.post({ | |
url:url, | |
formData: formData, | |
headers: headers | |
}, function optionalCallback(err, httpResponse, body) { | |
if (err) { | |
return console.error('upload failed:', err); | |
} | |
console.log("httpResponse.statusCode:", httpResponse.statusCode); | |
console.log('Server responded with:', body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment