1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00

support attachments s3

This commit is contained in:
Nguyễn Hải Quang 2024-11-09 18:49:26 +07:00
parent f6ea10df97
commit 84b0f91b44
10 changed files with 392 additions and 14 deletions

View file

@ -51,7 +51,18 @@ module.exports = {
if (attachment) {
try {
rimraf.sync(path.join(sails.config.custom.attachmentsPath, attachment.dirname));
const type = attachment.type || 'local';
if (type === 's3') {
const client = await sails.helpers.attachments.getSimpleStorageServiceClient();
if (client) {
const file1 = `${attachment.dirname}/${attachment.filename}`;
const file2 = `${attachment.dirname}/thumbnails/cover-256.png`;
await client.delete({ Key: file1 });
await client.delete({ Key: file2 });
}
} else {
rimraf.sync(path.join(sails.config.custom.attachmentsPath, attachment.dirname));
}
} catch (error) {
console.warn(error.stack); // eslint-disable-line no-console
}