mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
parent
0ad73ee0c0
commit
21e2eabd60
13 changed files with 551 additions and 71 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import fs from 'fs';
|
||||
import FileStoreStrategy, {FileStoreStrategyFilesystem, FileStoreStrategyGridFs} from './fileStoreStrategy'
|
||||
import FileStoreStrategy, {FileStoreStrategyFilesystem, FileStoreStrategyGridFs, FileStoreStrategyS3} from './fileStoreStrategy'
|
||||
|
||||
const insertActivity = (fileObj, activityType) =>
|
||||
Activities.insert({
|
||||
|
|
@ -70,3 +70,32 @@ export class AttachmentStoreStrategyFilesystem extends FileStoreStrategyFilesyst
|
|||
insertActivity(this.fileObj, 'deleteAttachment');
|
||||
}
|
||||
}
|
||||
|
||||
/** Strategy to store attachments at filesystem */
|
||||
export class AttachmentStoreStrategyS3 extends FileStoreStrategyS3 {
|
||||
|
||||
/** constructor
|
||||
* @param s3Bucket use this S3 Bucket
|
||||
* @param fileObj the current file object
|
||||
* @param versionName the current version
|
||||
*/
|
||||
constructor(s3Bucket, fileObj, versionName) {
|
||||
super(s3Bucket, fileObj, versionName);
|
||||
}
|
||||
|
||||
/** after successfull upload */
|
||||
onAfterUpload() {
|
||||
super.onAfterUpload();
|
||||
// If the attachment doesn't have a source field or its source is different than import
|
||||
if (!this.fileObj.meta.source || this.fileObj.meta.source !== 'import') {
|
||||
// Add activity about adding the attachment
|
||||
insertActivity(this.fileObj, 'addAttachment');
|
||||
}
|
||||
}
|
||||
|
||||
/** after file remove */
|
||||
onAfterRemove() {
|
||||
super.onAfterRemove();
|
||||
insertActivity(this.fileObj, 'deleteAttachment');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue