fixed file naming
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { File } from 'lucide-react';
|
||||
const FileBox = ({ url }: { url: string }) => {
|
||||
const fileNameWithSuffix = url.split('/').pop(); // 'attachment.pdf-321321321312312'
|
||||
const fileNameWithSuffix = url.split('/').pop();
|
||||
const fullFileName = fileNameWithSuffix?.replace(/-\d+$/, '');
|
||||
const filename = fullFileName?.slice(0, 25) + '...';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ SERVER_PORT=3000 #DO NOT CHANGE
|
||||
JWT_SECRET=fdsfsdfds@
|
||||
ORIGIN=http://localhost:5173
|
||||
|
||||
PG_HOST=192.168.0.47
|
||||
PG_USER=postgres
|
||||
PG_PASSWORD=haslo
|
||||
PG_DATABASE=relay
|
||||
PG_HOST=192.168.0.47
|
||||
@@ -6,7 +6,7 @@ const client = new Client({
|
||||
password: process.env.PG_PASSWORD,
|
||||
database: process.env.PG_DATABASE,
|
||||
host: process.env.PG_HOST,
|
||||
port: 5432,
|
||||
port: 5433,
|
||||
});
|
||||
|
||||
client
|
||||
|
||||
@@ -55,9 +55,11 @@ const storage = multer.diskStorage({
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
const uniqueSuffix = Date.now() + "-" + Math.round(Math.random() * 1e9);
|
||||
const extension = extname(file.originalname);
|
||||
const extension = extname(file.originalname).toString();
|
||||
const originalName = file.originalname;
|
||||
const filename = originalName?.substring(0, originalName.lastIndexOf("."));
|
||||
//const finalName = uniqueSuffix + extension;
|
||||
const finalName = `${file.originalname}-${Math.round(Math.random() * 1e9)}`;
|
||||
const finalName = `${filename}-${Math.round(Math.random() * 1e9)}${extension}`;
|
||||
file.finalName = finalName;
|
||||
cb(null, finalName);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user