- added new sound files
- new functionality to upload files - need to get and locatate uploaded files
This commit is contained in:
@@ -10,10 +10,7 @@ type BlobFileUpload = {
|
||||
};
|
||||
};
|
||||
|
||||
export async function sendBlobFileUpload({
|
||||
file,
|
||||
opts,
|
||||
}: BlobFileUpload): Promise<string> {
|
||||
export async function sendBlobFileUpload({ file, opts }: BlobFileUpload): Promise<string> {
|
||||
if (!file) throw new Error("No file supplied");
|
||||
if (!opts?.uploadUrl) throw new Error("No URL supplied");
|
||||
|
||||
@@ -42,9 +39,7 @@ export async function sendBlobFileUpload({
|
||||
const bodyText = await resp.text();
|
||||
|
||||
if (!resp.ok) {
|
||||
throw new Error(
|
||||
`Upload failed (${resp.status} ${resp.statusText}) from ${opts.uploadUrl} — ${bodyText}`
|
||||
);
|
||||
throw new Error(`Upload failed (${resp.status} ${resp.statusText}) from ${opts.uploadUrl} — ${bodyText}`);
|
||||
}
|
||||
|
||||
return bodyText;
|
||||
@@ -54,9 +49,7 @@ export async function sendBlobFileUpload({
|
||||
}
|
||||
// In browsers, fetch throws TypeError on network-level failures
|
||||
if (err instanceof TypeError) {
|
||||
throw new Error(
|
||||
`HTTP error uploading to ${opts.uploadUrl}: ${err.message}`
|
||||
);
|
||||
throw new Error(`HTTP error uploading to ${opts.uploadUrl}: ${err.message}`);
|
||||
}
|
||||
// Todo: fix error message response
|
||||
return `Hotlist Load OK`;
|
||||
|
||||
Reference in New Issue
Block a user