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

support project background + user avatar

This commit is contained in:
Nguyễn Hải Quang 2024-11-10 00:26:49 +07:00
parent 84b0f91b44
commit e84a2837ab
13 changed files with 223 additions and 46 deletions

View file

@ -23,11 +23,11 @@ module.exports = {
const rootPath = path.join(sails.config.custom.attachmentsPath, dirname);
const filePath = path.join(rootPath, filename);
if (sails.config.custom.attachmentsS3) {
const client = await sails.helpers.attachments.getSimpleStorageServiceClient();
if (sails.config.custom.s3Config) {
const client = await sails.helpers.utils.getSimpleStorageServiceClient();
const s3Image = await client.upload({
Body: fs.createReadStream(inputs.file.fd),
Key: `${dirname}/${filename}`,
Key: `attachments/${dirname}/${filename}`,
ContentType: inputs.file.type,
});
@ -72,7 +72,7 @@ module.exports = {
)
.toBuffer();
const s3Thumb = await client.upload({
Key: `${dirname}/thumbnails/cover-256.${thumbnailsExtension}`,
Key: `attachments/${dirname}/thumbnails/cover-256.${thumbnailsExtension}`,
Body: resizeBuffer,
ContentType: inputs.file.type,
});
@ -83,6 +83,12 @@ module.exports = {
}
}
try {
rimraf.sync(inputs.file.fd);
} catch (error) {
console.warn(error.stack); // eslint-disable-line no-console
}
return fileData;
}