From 8ee338647003e870ffc986b7e99e1674a149ede0 Mon Sep 17 00:00:00 2001 From: mntmn Date: Mon, 8 Jan 2018 12:41:38 +0100 Subject: [PATCH] fix tmp dir in artifact uploader --- helpers/artifact_converter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers/artifact_converter.js b/helpers/artifact_converter.js index 3605a90..d6f468d 100644 --- a/helpers/artifact_converter.js +++ b/helpers/artifact_converter.js @@ -7,6 +7,7 @@ const fs = require('fs'); const Models = require('../models/schema'); const uploader = require('../helpers/uploader'); const path = require('path'); +const os = require('os'); const fileExtensionMap = { ".amr" : "audio/AMR", @@ -245,13 +246,12 @@ function resizeAndUpload(a, size, max, fileName, localFilePath, callback) { if (max>320 || size.width > max || size.height > max) { var resizedFileName = max + "_"+fileName; var s3Key = "s"+ a.space_id.toString() + "/a" + a._id.toString() + "/" + resizedFileName; - var localResizedFilePath = "/tmp/"+resizedFileName; + var localResizedFilePath = os.tmpdir()+"/"+resizedFileName; gm(localFilePath).resize(max, max).autoOrient().write(localResizedFilePath, function (err) { if(!err) { uploader.uploadFile(s3Key, "image/jpeg", localResizedFilePath, function(err, url) { if (err) callback(err); else{ - console.log(localResizedFilePath); fs.unlink(localResizedFilePath, function (err) { if (err) { console.error(err);