refactor: Upload file to storage, and then pass attachmentId to collections.import
This avoids having large file uploads going directly to the server and allows us to fetch it async into a worker process
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
import path from "path";
|
||||
import { DataTypes, sequelize } from "../sequelize";
|
||||
import { deleteFromS3 } from "../utils/s3";
|
||||
import { deleteFromS3, getFileByKey } from "../utils/s3";
|
||||
|
||||
const Attachment = sequelize.define(
|
||||
"attachment",
|
||||
@@ -47,6 +47,9 @@ const Attachment = sequelize.define(
|
||||
isPrivate: function () {
|
||||
return this.acl === "private";
|
||||
},
|
||||
buffer: function () {
|
||||
return getFileByKey(this.key);
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user