mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
Save files serverside with filename ObjectID, without filename.
Thanks to g-roliveira, iamabrantes, Floaz, koelle25, scott-dunt, mfilser and xet7 ! Fixes #4416
This commit is contained in:
parent
f0a6fa68ea
commit
76ac070f9b
2 changed files with 16 additions and 3 deletions
|
@ -72,7 +72,12 @@ Attachments = new FilesCollection({
|
|||
filenameWithoutExtension = Math.random().toString(36).slice(2);
|
||||
fileId = Math.random().toString(36).slice(2);
|
||||
}
|
||||
const ret = fileId + "-original-" + filenameWithoutExtension;
|
||||
|
||||
// OLD:
|
||||
//const ret = fileId + "-original-" + filenameWithoutExtension;
|
||||
// NEW: Save file only with filename of ObjectID, not including filename.
|
||||
// Fixes https://github.com/wekan/wekan/issues/4416#issuecomment-1510517168
|
||||
const ret = fileId;
|
||||
// remove fileId from meta, it was only stored there to have this information here in the namingFunction function
|
||||
return ret;
|
||||
},
|
||||
|
|
|
@ -1250,7 +1250,11 @@ Migrations.add('migrate-attachments-collectionFS-to-ostrioFiles', () => {
|
|||
AttachmentsOld.find().forEach(function(fileObj) {
|
||||
const newFileName = fileObj.name();
|
||||
const storagePath = Attachments.storagePath({});
|
||||
const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
||||
// OLD:
|
||||
// const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
||||
// NEW: Save file only with filename of ObjectID, not including filename.
|
||||
// Fixes https://github.com/wekan/wekan/issues/4416#issuecomment-1510517168
|
||||
const filePath = path.join(storagePath, `${fileObj._id}`);
|
||||
|
||||
// This is "example" variable, change it to the userId that you might be using.
|
||||
const userId = fileObj.userId;
|
||||
|
@ -1318,7 +1322,11 @@ Migrations.add('migrate-avatars-collectionFS-to-ostrioFiles', () => {
|
|||
AvatarsOld.find().forEach(function(fileObj) {
|
||||
const newFileName = fileObj.name();
|
||||
const storagePath = Avatars.storagePath({});
|
||||
const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
||||
// OLD:
|
||||
// const filePath = path.join(storagePath, `${fileObj._id}-${newFileName}`);
|
||||
// NEW: Save file only with filename of ObjectID, not including filename.
|
||||
// Fixes https://github.com/wekan/wekan/issues/4416#issuecomment-1510517168
|
||||
const filePath = path.join(storagePath, `${fileObj._id}`);
|
||||
|
||||
// This is "example" variable, change it to the userId that you might be using.
|
||||
const userId = fileObj.userId;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue