fix tmp dir in artifact uploader
This commit is contained in:
parent
0d92343d55
commit
8ee3386470
@ -7,6 +7,7 @@ const fs = require('fs');
|
|||||||
const Models = require('../models/schema');
|
const Models = require('../models/schema');
|
||||||
const uploader = require('../helpers/uploader');
|
const uploader = require('../helpers/uploader');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const os = require('os');
|
||||||
|
|
||||||
const fileExtensionMap = {
|
const fileExtensionMap = {
|
||||||
".amr" : "audio/AMR",
|
".amr" : "audio/AMR",
|
||||||
@ -245,13 +246,12 @@ function resizeAndUpload(a, size, max, fileName, localFilePath, callback) {
|
|||||||
if (max>320 || size.width > max || size.height > max) {
|
if (max>320 || size.width > max || size.height > max) {
|
||||||
var resizedFileName = max + "_"+fileName;
|
var resizedFileName = max + "_"+fileName;
|
||||||
var s3Key = "s"+ a.space_id.toString() + "/a" + a._id.toString() + "/" + resizedFileName;
|
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) {
|
gm(localFilePath).resize(max, max).autoOrient().write(localResizedFilePath, function (err) {
|
||||||
if(!err) {
|
if(!err) {
|
||||||
uploader.uploadFile(s3Key, "image/jpeg", localResizedFilePath, function(err, url) {
|
uploader.uploadFile(s3Key, "image/jpeg", localResizedFilePath, function(err, url) {
|
||||||
if (err) callback(err);
|
if (err) callback(err);
|
||||||
else{
|
else{
|
||||||
console.log(localResizedFilePath);
|
|
||||||
fs.unlink(localResizedFilePath, function (err) {
|
fs.unlink(localResizedFilePath, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user