diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-27 12:48:06 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-27 12:48:06 +0100 |
| commit | 994f212275f71cc48c4938f0e0cc1fa0dc4eee38 (patch) | |
| tree | b30fd4a635b1a8a04ee4975a67e77aecde4eb22c /lib/upload.js | |
| parent | 1fac54a69a4fd21b28953f2073904cbd3aee8577 (diff) | |
| parent | 4d66be70dde0b6918291d70b08b50bc952d7052a (diff) | |
shader-saving endpoint
Diffstat (limited to 'lib/upload.js')
| -rw-r--r-- | lib/upload.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/upload.js b/lib/upload.js index f0ea132..82ea9b5 100644 --- a/lib/upload.js +++ b/lib/upload.js @@ -15,6 +15,10 @@ var acceptableuploadTypes = { 'image/png': 'png' } +module.exports.getExtension = function(file) { + return acceptableuploadTypes[file.mimetype] +} + module.exports.put = function (key, file, opt) { var fileSize, fileType, filename var err @@ -22,10 +26,10 @@ module.exports.put = function (key, file, opt) { var ts = moment().format('YYYYMMDD') - var extension = acceptableuploadTypes[file.mimetype] - filename = crypto.createHash('md5').update(file.buffer).digest('hex') + "." + extension; + var extension = this.getExtension(file) + filename = opt.filename || crypto.createHash('md5').update(file.buffer).digest('hex') + "." + extension; - var remote_path = process.env.S3_DIR + filename + var remote_path = (opt.path || process.env.S3_DIR) + filename if (! extension) { err = "Unacceptable filetype" |
