From f42615675ff7b5e643be89cab95ee29680008164 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 11 Nov 2025 23:26:51 +0000 Subject: [PATCH] completionId: cgen-8a563a0fea114c38b7bdca624ae4fdc5 cgen-8a563a0fea114c38b7bdca624ae4fdc5 --- client/pages/ethos/ArtistSettings.tsx | 33 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/client/pages/ethos/ArtistSettings.tsx b/client/pages/ethos/ArtistSettings.tsx index 128f14d1..915dd8ae 100644 --- a/client/pages/ethos/ArtistSettings.tsx +++ b/client/pages/ethos/ArtistSettings.tsx @@ -217,8 +217,24 @@ export default function ArtistSettings() { if (!user || !currentFile) return; try { - // TODO: Upload file to Supabase Storage - // For now, just create track record with placeholder file_url + toast.loading({ + title: "Uploading track...", + description: "Please wait while we upload your file to secure storage", + }); + + // Get audio duration + let durationSeconds = 0; + try { + durationSeconds = Math.round(await getAudioDuration(currentFile)); + } catch (error) { + console.warn("Could not determine audio duration:", error); + durationSeconds = Math.floor(currentFile.size / 16000); // Fallback estimate + } + + // Upload file to Supabase Storage + const fileUrl = await ethosStorage.uploadTrackFile(currentFile, user.id); + + // Create track record in database const res = await fetch(`/api/ethos/tracks`, { method: "POST", headers: { @@ -227,24 +243,25 @@ export default function ArtistSettings() { }, body: JSON.stringify({ ...metadata, - file_url: `ethos-tracks/${user.id}/${currentFile.name}`, - duration_seconds: Math.floor(currentFile.size / 16000), // Rough estimate + file_url: fileUrl, + duration_seconds: durationSeconds, }), }); if (res.ok) { toast.success({ - title: "Track uploaded", - description: "Your track has been added to your portfolio", + title: "Track uploaded successfully! 🎵", + description: "Your track has been added to your portfolio and is ready to share", }); setShowMetadataForm(false); setCurrentFile(null); } else { - throw new Error("Failed to upload track"); + throw new Error("Failed to create track record"); } } catch (error) { + console.error("Upload error:", error); toast.error({ - title: "Error", + title: "Upload failed", description: String(error), }); }