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:
parent
84b0f91b44
commit
e84a2837ab
13 changed files with 223 additions and 46 deletions
|
@ -0,0 +1,45 @@
|
|||
const AWS = require('aws-sdk');
|
||||
|
||||
class S3Client {
|
||||
constructor(options) {
|
||||
AWS.config.update({
|
||||
accessKeyId: options.accessKeyId,
|
||||
secretAccessKey: options.secretAccessKey,
|
||||
region: options.region,
|
||||
});
|
||||
this.bucket = options.bucket;
|
||||
this.client = new AWS.S3({
|
||||
endpoint: options.endpoint,
|
||||
});
|
||||
}
|
||||
|
||||
upload({ Key, Body, ContentType }) {
|
||||
return this.client
|
||||
.upload({
|
||||
Bucket: this.bucket,
|
||||
Key,
|
||||
Body,
|
||||
ContentType,
|
||||
ACL: 'public-read',
|
||||
})
|
||||
.promise();
|
||||
}
|
||||
|
||||
delete({ Key }) {
|
||||
return this.client
|
||||
.deleteObject({
|
||||
Bucket: this.bucket,
|
||||
Key,
|
||||
})
|
||||
.promise();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fn() {
|
||||
if (sails.config.custom.s3Config) {
|
||||
return new S3Client(sails.config.custom.s3Config);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue