Local file storage (#5763)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Apoorv Mishra
2023-09-21 03:42:03 +05:30
committed by GitHub
parent fea50feb0d
commit 67b1fe5514
41 changed files with 893 additions and 139 deletions

View File

@@ -33,6 +33,7 @@ import {
SearchQuery,
Pin,
} from "@server/models";
import AttachmentHelper from "@server/models/helpers/AttachmentHelper";
export async function buildApiKey(overrides: Partial<ApiKey> = {}) {
if (!overrides.userId) {
@@ -420,7 +421,10 @@ export async function buildFileOperation(
});
}
export async function buildAttachment(overrides: Partial<Attachment> = {}) {
export async function buildAttachment(
overrides: Partial<Attachment> = {},
fileName?: string
) {
if (!overrides.teamId) {
const team = await buildTeam();
overrides.teamId = team.id;
@@ -441,11 +445,14 @@ export async function buildAttachment(overrides: Partial<Attachment> = {}) {
overrides.documentId = document.id;
}
const id = uuidv4();
const acl = overrides.acl || "public-read";
const name = fileName || faker.system.fileName();
return Attachment.create({
key: `uploads/key/to/${faker.system.fileName}.png`,
key: AttachmentHelper.getKey({ acl, id, name, userId: overrides.userId }),
contentType: "image/png",
size: 100,
acl: "public-read",
acl,
createdAt: new Date("2018-01-02T00:00:00.000Z"),
updatedAt: new Date("2018-01-02T00:00:00.000Z"),
...overrides,