summaryrefslogtreecommitdiff
path: root/lib/upload.js
diff options
context:
space:
mode:
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"