mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 04:56:00 +00:00
uploads - moved logic to FE because of plugins
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user