mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
revert changes to IPFSUploader and S3Uploader
This commit is contained in:
parent
57725fa9ac
commit
e95441f5b9
2 changed files with 14 additions and 15 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import { NUploader } from '@nostrify/nostrify';
|
||||
import { z } from 'zod';
|
||||
import { getOptionalNip94Metadata } from '@/utils/image-metadata.ts';
|
||||
|
||||
export interface IPFSUploaderOpts {
|
||||
baseUrl: string;
|
||||
|
|
@ -38,13 +37,12 @@ export class IPFSUploader implements NUploader {
|
|||
|
||||
const { Hash: cid } = IPFSUploader.schema().parse(await response.json());
|
||||
|
||||
return Object.entries({
|
||||
url: new URL(`/ipfs/${cid}`, this.baseUrl).toString(),
|
||||
m: file.type,
|
||||
cid,
|
||||
size: file.size.toString(),
|
||||
...await getOptionalNip94Metadata(file),
|
||||
}) as [['url', string], ...string[][]];
|
||||
return [
|
||||
['url', new URL(`/ipfs/${cid}`, this.baseUrl).toString()],
|
||||
['m', file.type],
|
||||
['cid', cid],
|
||||
['size', file.size.toString()],
|
||||
];
|
||||
}
|
||||
|
||||
async delete(cid: string, opts?: { signal?: AbortSignal }): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import { encodeHex } from '@std/encoding/hex';
|
|||
import { extensionsByType } from '@std/media-types';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { getOptionalNip94Metadata } from '@/utils/image-metadata.ts';
|
||||
|
||||
export interface S3UploaderOpts {
|
||||
endPoint: string;
|
||||
|
|
@ -45,12 +44,14 @@ export class S3Uploader implements NUploader {
|
|||
|
||||
const path = (pathStyle && bucket) ? join(bucket, filename) : filename;
|
||||
|
||||
return Object.entries({
|
||||
url: new URL(path, Conf.mediaDomain).toString(),
|
||||
m: file.type,
|
||||
size: file.size.toString(),
|
||||
...await getOptionalNip94Metadata(file),
|
||||
}) as [['url', string], ...string[][]];
|
||||
const url = new URL(path, Conf.mediaDomain).toString();
|
||||
|
||||
return [
|
||||
['url', url],
|
||||
['m', file.type],
|
||||
['x', sha256],
|
||||
['size', file.size.toString()],
|
||||
];
|
||||
}
|
||||
|
||||
async delete(objectName: string) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue