mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Add media upload functionality and create uploads
folder
This commit is contained in:
parent
ca94c35bc4
commit
8fa16d4e09
7 changed files with 318 additions and 16 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue