-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.js
41 lines (30 loc) · 935 Bytes
/
upload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var Uploader = function() {
};
var mustache = require('mustache');
var Contextualizer = require('./contextualize');
var request = require('request')
Uploader.prototype.upload = function(file, text, avatar, image) {
var filename = file;
var options = {
method: 'POST',
url: 'https://api.smartling.com/v1/file/upload',
qs:
{ file: '@' + filename + '.json;type=text/plain',
apiKey: 'd39e8d85-3d7b-46f5-ad79-30edf0ccf7b3',
projectId: 'c5c7a69ed',
fileType: 'json',
fileUri: filename,
localesToApprove: 'fr-FR',
localesToApprove: 'de-DE',
callbackUrl: 'https://hsnodesmartlingsocial.herokuapp.com/translated/'
}
};
console.log(options.qs.file)
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
var contextualizer = new Contextualizer;
contextualizer.contextualize(text, avatar, image);
});
};
module.exports = Uploader;