-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathuploadSplashscreen.js
40 lines (35 loc) · 1.07 KB
/
uploadSplashscreen.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
var http = require('http');
var multiparty = require('multiparty');
var dacast = require('dacast')('YOUR_API_KEY');
http.createServer(function(req, res) {
/*
* Upload a splashscreen for a package
*/
if (req.url === '/upload' && req.method === 'POST') {
// Parse a file upload
var form = new multiparty.Form();
form.parse(req, function(err, fields, files) {
dacast.package.splashscreen.upload({
id: 'YOUR_PACKAGE_ID', // Required - Set your own package id
file: {
originalFilename: files.upload[0]['originalFilename'],
path: files.upload[0]['path'],
} //Required
}, function success() {
console.log('success');
}, function(error) {
console.log('error',error);
});
});
return;
};
res.writeHead(200, {
'content-type': 'text/html'
});
res.end(
'<form action="/upload" enctype="multipart/form-data" method="post">' +
'<input type="file" name="upload" multiple="multiple"><br>' +
'<input type="submit" value="Upload">' +
'</form>'
);
}).listen(8080);