summaryrefslogtreecommitdiff
path: root/lib/upload.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-27 12:48:06 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-27 12:48:06 +0100
commit994f212275f71cc48c4938f0e0cc1fa0dc4eee38 (patch)
treeb30fd4a635b1a8a04ee4975a67e77aecde4eb22c /lib/upload.js
parent1fac54a69a4fd21b28953f2073904cbd3aee8577 (diff)
parent4d66be70dde0b6918291d70b08b50bc952d7052a (diff)
shader-saving endpoint
Diffstat (limited to 'lib/upload.js')
-rw-r--r--lib/upload.js10
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"