mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
feat: Add S3 support for uploads (#938)
This commit is contained in:
parent
f6ea10df97
commit
950a070589
16 changed files with 579 additions and 24 deletions
|
@ -50,6 +50,24 @@ module.exports = {
|
|||
const attachment = await Attachment.archiveOne(inputs.record.id);
|
||||
|
||||
if (attachment) {
|
||||
try {
|
||||
const type = attachment.type || 'local';
|
||||
if (type === 's3') {
|
||||
const client = await sails.helpers.utils.getSimpleStorageServiceClient();
|
||||
if (client) {
|
||||
if (attachment.url) {
|
||||
const parsedUrl = new URL(attachment.url);
|
||||
await client.delete({ Key: parsedUrl.pathname.replace(/^\/+/, '') });
|
||||
}
|
||||
if (attachment.thumb) {
|
||||
const parsedUrl = new URL(attachment.thumb);
|
||||
await client.delete({ Key: parsedUrl.pathname.replace(/^\/+/, '') });
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(error.stack); // eslint-disable-line no-console
|
||||
}
|
||||
try {
|
||||
rimraf.sync(path.join(sails.config.custom.attachmentsPath, attachment.dirname));
|
||||
} catch (error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue