mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-05 06:34:24 +01:00
Add unattached_media table, insert one when uploading a file
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { AppController } from '@/app.ts';
|
||||
import { Conf } from '@/config.ts';
|
||||
import { insertUnattachedMedia } from '@/db/unattached-media.ts';
|
||||
import { z } from '@/deps.ts';
|
||||
import { fileSchema } from '@/schema.ts';
|
||||
import { configUploader as uploader } from '@/uploaders/config.ts';
|
||||
@@ -27,6 +28,17 @@ const mediaController: AppController = async (c) => {
|
||||
const { file, description } = result.data;
|
||||
const { cid } = await uploader.upload(file);
|
||||
|
||||
await insertUnattachedMedia({
|
||||
pukey: c.get('pubkey')!,
|
||||
cid,
|
||||
data: {
|
||||
name: file.name,
|
||||
mime: file.type,
|
||||
size: file.size,
|
||||
description,
|
||||
},
|
||||
});
|
||||
|
||||
const url = new URL(`/ipfs/${cid}`, Conf.mediaDomain).toString();
|
||||
|
||||
return c.json({
|
||||
|
||||
Reference in New Issue
Block a user