Add a configUploader module to select the uploader based on config

This commit is contained in:
Alex Gleason
2023-09-08 16:04:55 -05:00
parent 34acc99000
commit 8ae89462b7
3 changed files with 34 additions and 14 deletions

View File

@@ -2,6 +2,7 @@ import { AppController } from '@/app.ts';
import { Conf } from '@/config.ts';
import { z } from '@/deps.ts';
import { fileSchema } from '@/schema.ts';
import { configUploader as uploader } from '@/uploaders/config.ts';
import { parseBody } from '@/utils/web.ts';
const mediaBodySchema = z.object({
@@ -20,7 +21,7 @@ const mediaController: AppController = async (c) => {
try {
const { file, description } = result.data;
const { cid } = await Conf.uploader.upload(file);
const { cid } = await uploader.upload(file);
const url = new URL(`/ipfs/${cid}`, Conf.mediaDomain).toString();