-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMultipart_File.js
More file actions
37 lines (28 loc) · 841 Bytes
/
Multipart_File.js
File metadata and controls
37 lines (28 loc) · 841 Bytes
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
// Generated by CoffeeScript 1.10.0
(function() {
var app, crypto, express, multer, path, storage;
express = require('express');
multer = require('multer');
path = require('path');
crypto = require('crypto');
app = new express();
storage = multer.diskStorage({
destination: './uploads',
filename: function(req, file, cb) {
return crypto.pseudoRandomBytes(16, function(err, raw) {
if (err) {
return cb(err);
}
return cb(null, "" + (raw.toString('hex')) + (path.extname(file.originalname)));
});
}
});
app.post('/', multer({
storage: storage
}).single('upload'), function(req, res) {
console.log(req.file);
console.log(req.body);
return res.status(204).end();
});
app.listen(3000, console.log("Listening on port 3000"));
}).call(this);