Fix reference audio upload URL and validation
- Fix double /audio/ prefix in reference audio URLs (upload() already returns the public path) - Allow reference audio as alternative to style/lyrics in custom mode validation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -152,7 +152,7 @@ router.post('/upload-audio', authMiddleware, audioUpload.single('audio'), async
|
|||||||
const ext = extFromName || extFromType || '.audio';
|
const ext = extFromName || extFromType || '.audio';
|
||||||
const key = `references/${req.user!.id}/${Date.now()}-${generateUUID()}${ext}`;
|
const key = `references/${req.user!.id}/${Date.now()}-${generateUUID()}${ext}`;
|
||||||
const storedKey = await storage.upload(key, req.file.buffer, req.file.mimetype);
|
const storedKey = await storage.upload(key, req.file.buffer, req.file.mimetype);
|
||||||
const publicUrl = storage.getPublicUrl(storedKey);
|
const publicUrl = storedKey;
|
||||||
|
|
||||||
res.json({ url: publicUrl, key: storedKey });
|
res.json({ url: publicUrl, key: storedKey });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -221,8 +221,8 @@ router.post('/', authMiddleware, async (req: AuthenticatedRequest, res: Response
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customMode && !style && !lyrics) {
|
if (customMode && !style && !lyrics && !referenceAudioUrl) {
|
||||||
res.status(400).json({ error: 'Style or lyrics required for custom mode' });
|
res.status(400).json({ error: 'Style, lyrics, or reference audio required for custom mode' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user