completionId: cgen-8a563a0fea114c38b7bdca624ae4fdc5
cgen-8a563a0fea114c38b7bdca624ae4fdc5
This commit is contained in:
parent
00d6369a90
commit
f42615675f
1 changed files with 25 additions and 8 deletions
|
|
@ -217,8 +217,24 @@ export default function ArtistSettings() {
|
||||||
if (!user || !currentFile) return;
|
if (!user || !currentFile) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: Upload file to Supabase Storage
|
toast.loading({
|
||||||
// For now, just create track record with placeholder file_url
|
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`, {
|
const res = await fetch(`/api/ethos/tracks`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -227,24 +243,25 @@ export default function ArtistSettings() {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
...metadata,
|
...metadata,
|
||||||
file_url: `ethos-tracks/${user.id}/${currentFile.name}`,
|
file_url: fileUrl,
|
||||||
duration_seconds: Math.floor(currentFile.size / 16000), // Rough estimate
|
duration_seconds: durationSeconds,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
toast.success({
|
toast.success({
|
||||||
title: "Track uploaded",
|
title: "Track uploaded successfully! 🎵",
|
||||||
description: "Your track has been added to your portfolio",
|
description: "Your track has been added to your portfolio and is ready to share",
|
||||||
});
|
});
|
||||||
setShowMetadataForm(false);
|
setShowMetadataForm(false);
|
||||||
setCurrentFile(null);
|
setCurrentFile(null);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Failed to upload track");
|
throw new Error("Failed to create track record");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error("Upload error:", error);
|
||||||
toast.error({
|
toast.error({
|
||||||
title: "Error",
|
title: "Upload failed",
|
||||||
description: String(error),
|
description: String(error),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue