mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
Fix duplicate file upload
Currently, we face an issue when a file with the same name is uploaded more than once: 1. It results in a unique key error in the database. 2. If the file is sent to S3, it overwrites the old file. To resolve this problem, I've implemented a solution where we concatenate the message ID to the filename. This approach ensures uniqueness for each uploaded file, even if users upload files with identical names multiple times in a chat. This change allows normal users to upload files with the same name multiple times in a chat without encountering errors or unintended file overwrites.
This commit is contained in:
parent
ebbba7b7e9
commit
2e43683835
@ -1992,7 +1992,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
|
||||
const mimetype = mime.getType(fileName).toString();
|
||||
|
||||
const fullName = join(`${this.instance.id}`, messageRaw.key.remoteJid, mediaType, fileName);
|
||||
const fullName = join(`${this.instance.id}`, messageRaw.key.remoteJid, `${messageRaw.key.id}`, mediaType, fileName);
|
||||
|
||||
await s3Service.uploadFile(fullName, buffer, size.fileLength?.low, {
|
||||
'Content-Type': mimetype,
|
||||
|
Loading…
Reference in New Issue
Block a user