|
|
|
@ -50,9 +50,7 @@ exports.uploadFile = async function(ctx) { |
|
|
|
const processedFileName = `${uuid.v4()}.${fileExtension}` |
|
|
|
|
|
|
|
return prepareUploadForS3({ |
|
|
|
...file, |
|
|
|
fileType: file.type, |
|
|
|
filePath: file.path, |
|
|
|
file, |
|
|
|
s3Key: `assets/${ctx.user.appId}/attachments/${processedFileName}`, |
|
|
|
s3, |
|
|
|
}) |
|
|
|
@ -70,6 +68,7 @@ exports.uploadFile = async function(ctx) { |
|
|
|
} |
|
|
|
|
|
|
|
async function processLocalFileUploads({ files, outputPath, instanceId }) { |
|
|
|
console.log("files", files) |
|
|
|
// create attachments dir if it doesnt exist
|
|
|
|
!fs.existsSync(outputPath) && fs.mkdirSync(outputPath, { recursive: true }) |
|
|
|
|
|
|
|
@ -78,12 +77,20 @@ async function processLocalFileUploads({ files, outputPath, instanceId }) { |
|
|
|
// filenames converted to UUIDs so they are unique
|
|
|
|
const processedFileName = `${uuid.v4()}.${fileExtension}` |
|
|
|
|
|
|
|
console.log(file) |
|
|
|
// {
|
|
|
|
// name: 'backspace-solid.svg',
|
|
|
|
// path: '/Users/martinmckeaveney/Downloads/backspace-solid.svg',
|
|
|
|
// size: 813,
|
|
|
|
// type: 'image/svg+xml'
|
|
|
|
// }
|
|
|
|
|
|
|
|
return { |
|
|
|
...file, |
|
|
|
name: file.name, |
|
|
|
path: file.path, |
|
|
|
size: file.size, |
|
|
|
type: file.type, |
|
|
|
processedFileName, |
|
|
|
extension: fileExtension, |
|
|
|
// extension: fileExtension,
|
|
|
|
outputPath: join(outputPath, processedFileName), |
|
|
|
url: join("/attachments", processedFileName), |
|
|
|
} |
|
|
|
|