uploads - moved logic to FE because of plugins

This commit is contained in:
Jan Prochazka
2020-11-22 09:14:19 +01:00
parent 7d1c0c5c18
commit 3cdba4339f
7 changed files with 68 additions and 45 deletions

View File

@@ -2,20 +2,20 @@ const path = require('path');
const { uploadsdir } = require('../utility/directories');
const uuidv1 = require('uuid/v1');
const extensions = [
{
ext: '.xlsx',
type: 'excel',
},
{
ext: '.jsonl',
type: 'jsonl',
},
{
ext: '.csv',
type: 'csv',
},
];
// const extensions = [
// {
// ext: '.xlsx',
// type: 'excel',
// },
// {
// ext: '.jsonl',
// type: 'jsonl',
// },
// {
// ext: '.csv',
// type: 'csv',
// },
// ];
module.exports = {
upload_meta: {
@@ -31,19 +31,19 @@ module.exports = {
const uploadName = uuidv1();
const filePath = path.join(uploadsdir(), uploadName);
console.log(`Uploading file ${data.name}, size=${data.size}`);
let storageType = null;
let shortName = data.name;
for (const { ext, type } of extensions) {
if (data.name.endsWith(ext)) {
storageType = type;
shortName = data.name.slice(0, -ext.length);
}
}
// let storageType = null;
// let shortName = data.name;
// for (const { ext, type } of extensions) {
// if (data.name.endsWith(ext)) {
// storageType = type;
// shortName = data.name.slice(0, -ext.length);
// }
// }
data.mv(filePath, () => {
res.json({
originalName: data.name,
shortName,
storageType,
// shortName,
// storageType,
uploadName,
filePath,
});