fix: Unable to store/read in avatars bucket with local file system storage

closes #5873
This commit is contained in:
Tom Moor
2023-09-23 15:00:48 -04:00
parent 5c7c9ceeb1
commit 65d3c8309e
6 changed files with 48 additions and 25 deletions

View File

@@ -2,6 +2,12 @@ import { addHours } from "date-fns";
import { AttachmentPreset } from "@shared/types";
import env from "@server/env";
export enum Buckets {
public = "public",
uploads = "uploads",
avatars = "avatars",
}
export default class AttachmentHelper {
/**
* Get the upload location for the given upload details
@@ -22,7 +28,7 @@ export default class AttachmentHelper {
name: string;
userId: string;
}) {
const bucket = acl === "public-read" ? "public" : "uploads";
const bucket = acl === "public-read" ? Buckets.public : Buckets.uploads;
const keyPrefix = `${bucket}/${userId}/${id}`;
return `${keyPrefix}/${name}`;
}