diff --git a/src/hooks/useMetadata.ts b/src/hooks/useMetadata.ts index d815fd69..0c122010 100644 --- a/src/hooks/useMetadata.ts +++ b/src/hooks/useMetadata.ts @@ -11,22 +11,21 @@ export function useMetadata(metadataPtr?: string): UseTRPCQueryResult | File> { return useMutation({ mutationFn: async (data: Record | File) => { - const formData = new FormData(); - + let uploadData; if (!(data instanceof File)) { const blob = new Blob([JSON.stringify(data)], { type: "application/json", }); - formData.append("file", new File([blob], "metadata.json")); + uploadData = new File([blob], "metadata.json"); } else { - formData.append("file", data); + uploadData = data; } - return fetch(`/api/blob?filename=${data instanceof File ? data.name : "metadata.json"}`, { + return fetch(`/api/blob?filename=${uploadData.name}`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: formData, + body: uploadData, }).then(async (r) => { if (!r.ok) { throw new Error("Network error");