Fix subtitle file upload - remove pre-upload step and send file directly to API
This commit is contained in:
parent
3f7e62b776
commit
168f4e17ba
1 changed files with 2 additions and 37 deletions
|
|
@ -79,39 +79,7 @@ export default function SubtitlesPage() {
|
|||
|
||||
const handleFileUpload = async (uploadedFile: File) => {
|
||||
setFile(uploadedFile);
|
||||
setUploading(true);
|
||||
|
||||
try {
|
||||
const response = await assetsApi.upload(uploadedFile);
|
||||
setAssetId(response.data.id);
|
||||
toast.success('Video uploaded!');
|
||||
} catch (err: any) {
|
||||
if (err.response?.status === 409) {
|
||||
const existingAssetId = err.response.data.detail.asset_id;
|
||||
const shouldOverwrite = window.confirm(
|
||||
`File "${uploadedFile.name}" already exists. \nClick OK to Overwrite, Cancel to Use Existing.`
|
||||
);
|
||||
|
||||
if (shouldOverwrite) {
|
||||
try {
|
||||
const response = await assetsApi.upload(uploadedFile, undefined, false, true);
|
||||
setAssetId(response.data.id);
|
||||
toast.success('Video overwritten!');
|
||||
} catch (retryErr: any) {
|
||||
toast.error('Failed to overwrite video');
|
||||
setFile(null);
|
||||
}
|
||||
} else {
|
||||
setAssetId(existingAssetId);
|
||||
toast('Using existing file', { icon: 'ℹ️' });
|
||||
}
|
||||
} else {
|
||||
toast.error('Failed to upload video');
|
||||
setFile(null);
|
||||
}
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
toast.success('Video ready for processing!');
|
||||
};
|
||||
|
||||
const handleProcess = async () => {
|
||||
|
|
@ -253,9 +221,6 @@ export default function SubtitlesPage() {
|
|||
}}
|
||||
label="Upload a video for transcription"
|
||||
/>
|
||||
{uploading && (
|
||||
<p className="mt-2 text-sm text-forge-yellow">Uploading...</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Languages */}
|
||||
|
|
@ -407,7 +372,7 @@ export default function SubtitlesPage() {
|
|||
{/* Process Button */}
|
||||
<button
|
||||
onClick={handleProcess}
|
||||
disabled={loading || !file || uploading}
|
||||
disabled={loading || !file}
|
||||
className="btn-primary w-full flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
<Sparkles className="w-5 h-5" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue