revert changes to IPFSUploader and S3Uploader

This commit is contained in:
Siddharth Singh 2024-10-30 11:04:19 +05:30
parent 57725fa9ac
commit e95441f5b9
No known key found for this signature in database
2 changed files with 14 additions and 15 deletions

View file

@ -1,6 +1,5 @@
import { NUploader } from '@nostrify/nostrify'; import { NUploader } from '@nostrify/nostrify';
import { z } from 'zod'; import { z } from 'zod';
import { getOptionalNip94Metadata } from '@/utils/image-metadata.ts';
export interface IPFSUploaderOpts { export interface IPFSUploaderOpts {
baseUrl: string; baseUrl: string;
@ -38,13 +37,12 @@ export class IPFSUploader implements NUploader {
const { Hash: cid } = IPFSUploader.schema().parse(await response.json()); const { Hash: cid } = IPFSUploader.schema().parse(await response.json());
return Object.entries({ return [
url: new URL(`/ipfs/${cid}`, this.baseUrl).toString(), ['url', new URL(`/ipfs/${cid}`, this.baseUrl).toString()],
m: file.type, ['m', file.type],
cid, ['cid', cid],
size: file.size.toString(), ['size', file.size.toString()],
...await getOptionalNip94Metadata(file), ];
}) as [['url', string], ...string[][]];
} }
async delete(cid: string, opts?: { signal?: AbortSignal }): Promise<void> { async delete(cid: string, opts?: { signal?: AbortSignal }): Promise<void> {

View file

@ -7,7 +7,6 @@ import { encodeHex } from '@std/encoding/hex';
import { extensionsByType } from '@std/media-types'; import { extensionsByType } from '@std/media-types';
import { Conf } from '@/config.ts'; import { Conf } from '@/config.ts';
import { getOptionalNip94Metadata } from '@/utils/image-metadata.ts';
export interface S3UploaderOpts { export interface S3UploaderOpts {
endPoint: string; endPoint: string;
@ -45,12 +44,14 @@ export class S3Uploader implements NUploader {
const path = (pathStyle && bucket) ? join(bucket, filename) : filename; const path = (pathStyle && bucket) ? join(bucket, filename) : filename;
return Object.entries({ const url = new URL(path, Conf.mediaDomain).toString();
url: new URL(path, Conf.mediaDomain).toString(),
m: file.type, return [
size: file.size.toString(), ['url', url],
...await getOptionalNip94Metadata(file), ['m', file.type],
}) as [['url', string], ...string[][]]; ['x', sha256],
['size', file.size.toString()],
];
} }
async delete(objectName: string) { async delete(objectName: string) {