feat: update s3 upload to use put

This commit is contained in:
Henry
2025-05-16 23:27:32 +01:00
parent 702af24a25
commit 395c3acb81
4 changed files with 165 additions and 49 deletions

View File

@@ -74,20 +74,13 @@ export default function Avatar({
if (!response.ok) throw new Error("Failed to get pre-signed URL");
const { url, fields } = (await response.json()) as {
const { url } = (await response.json()) as {
url: string;
fields: Record<string, string>;
};
const formData = new FormData();
Object.entries(fields).forEach(([key, value]) => {
formData.append(key, value);
});
formData.append("file", file);
const uploadResponse = await fetch(url, {
method: "POST",
body: formData,
method: "PUT",
body: file,
});
if (!uploadResponse.ok) throw new Error("Failed to upload profile image");