Add media upload functionality and create uploads

folder
This commit is contained in:
Jesse Wierzbinski 2023-11-19 10:36:54 -10:00
parent ca94c35bc4
commit 8fa16d4e09
7 changed files with 318 additions and 16 deletions

View file

@ -6,6 +6,7 @@ import {
} from "@aws-sdk/client-s3";
import { ConfigType } from "@config";
import sharp from "sharp";
import { exists, mkdir } from "fs/promises";
class MediaBackend {
backend: string;
@ -223,6 +224,10 @@ export class LocalBackend extends MediaBackend {
const hash = await super.addMedia(media);
if (!(await exists(`${process.cwd()}/uploads`))) {
await mkdir(`${process.cwd()}/uploads`);
}
await Bun.write(Bun.file(`${process.cwd()}/uploads/${hash}`), media);
return hash;