Skip to content

Commit

Permalink
show upload error
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Apr 5, 2024
1 parent 5ad82a3 commit 0700f6a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
8 changes: 1 addition & 7 deletions frontend/src/components/object/ObjectUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,10 @@ const onUpload = async (event: any) => {
);
successfulFiles.value.push(file);
} catch (error: any) {
// show toasts
if (error?.response?.status === 409) {
toast.error(`Failed to upload file ${file.name}`, 'File already exists');
} else {
toast.error(`Failed to upload file ${file.name}`, error);
}
toast.error(`Failed to upload file ${file.name}`, error, {life: 0});
failedFiles.value.push(file);
} finally {
appStore.endUploading();
appStore.endIndeterminateLoading();
}
})
);
Expand Down
27 changes: 19 additions & 8 deletions frontend/src/store/objectStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,28 @@ export const useObjectStore = defineStore('object', () => {
},
axiosOptions?: AxiosRequestConfig
) {
appStore.beginIndeterminateLoading();

// Ensure x-amz-meta- prefix exists
if (headers.metadata) {
for (const meta of headers.metadata) {
if (!meta.key.startsWith('x-amz-meta-')) {
meta.key = `x-amz-meta-${meta.key}`;
try{
appStore.beginIndeterminateLoading();
// Ensure x-amz-meta- prefix exists
if (headers.metadata) {
for (const meta of headers.metadata) {
if (!meta.key.startsWith('x-amz-meta-')) {
meta.key = `x-amz-meta-${meta.key}`;
}
}
}
await objectService.createObject(object, headers, params, axiosOptions);
}
catch(error: any){
if (error.response?.status === 409){
throw new Error(error.response.data.detail);
} else {
throw new Error('Network error');
}
}
finally{
appStore.endIndeterminateLoading();
}
await objectService.createObject(object, headers, params, axiosOptions);
}

async function deleteObject(objectId: string, versionId?: string) {
Expand Down
1 change: 1 addition & 0 deletions frontend/tests/unit/store/objectStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ describe('Object Store', () => {
},
{ timeout: 0 }
);
expect(endIndeterminateLoadingSpy).toHaveBeenCalledTimes(1);
});
});

Expand Down

0 comments on commit 0700f6a

Please sign in to comment.