fix bug and errors
This commit is contained in:
@@ -63,30 +63,3 @@ export function putWithProgress(url, file, onProgress) {
|
||||
xhr.send(file);
|
||||
});
|
||||
}
|
||||
|
||||
export async function uploadAdVideo(advertisingId, file, onProgress) {
|
||||
const presignRes = await apiFetch(
|
||||
`${API_URL}/api/v1/admin/ads/${advertisingId}/video/presign-upload`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ contentType: file.type }),
|
||||
}
|
||||
);
|
||||
if (!presignRes.ok) throw new Error(`Presign failed (${presignRes.status})`);
|
||||
const { uploadUrl, sourceKey } = await presignRes.json();
|
||||
|
||||
await putWithProgress(uploadUrl, file, onProgress);
|
||||
|
||||
const confirmRes = await apiFetch(
|
||||
`${API_URL}/api/v1/admin/ads/${advertisingId}/video/confirm-upload`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ sourceKey }),
|
||||
}
|
||||
);
|
||||
if (!confirmRes.ok) throw new Error(`Confirm failed (${confirmRes.status})`);
|
||||
|
||||
return { sourceKey };
|
||||
}
|
||||
Reference in New Issue
Block a user