feat: Add support for S3 transfer acceleration

This commit is contained in:
Tom Moor
2022-03-02 21:12:38 -08:00
parent 4468d29740
commit 5e96145277
4 changed files with 31 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ import {
Table,
DataType,
} from "sequelize-typescript";
import { deleteFromS3, getFileByKey } from "@server/utils/s3";
import { publicS3Endpoint, deleteFromS3, getFileByKey } from "@server/utils/s3";
import Document from "./Document";
import Team from "./Team";
import User from "./User";
@@ -55,6 +55,14 @@ class Attachment extends BaseModel {
return getFileByKey(this.key);
}
/**
* Use this instead of url which will be deleted soon, the column is unneccessary
* and was not updated with the migraiton to the new s3 bucket.
*/
get canonicalUrl() {
return `${publicS3Endpoint()}/${this.key}`;
}
// hooks
@BeforeDestroy