Skip to content

Commit

Permalink
Adding timeout as input argument at service/store layer - if not pass…
Browse files Browse the repository at this point in the history
…ed default to 10000ms
  • Loading branch information
dcolic committed Mar 22, 2023
1 parent a6b1b83 commit 12509c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/object/ObjectUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const onUpload = async (event: any) => {
await Promise.allSettled(
event.files.map(async (file: File) => {
try {
await objectStore.createObject(file, bucketId);
//infinite timeout for big files upload to avoid timeout error
await objectStore.createObject(file, bucketId, 0);
successfulFiles.value.push(file);
} catch (error) {
toast.add({ severity: 'error', summary: 'Error', detail: `Failed to upload file ${file.name}`, life: 3000 });
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/services/objectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export default {
* Post an object
* @returns {Promise} An axios response
*/
createObject(object: any, bucketId?: string) {
createObject(object: any, bucketId?: string, timeout?: number) {
const config = {
headers: { 'Content-Type': 'multipart/form-data' },
params: { bucketId: bucketId },
};
const fd = new FormData();
fd.append('file', object);
return comsAxios(0).post(PATH, fd, config);
return comsAxios(timeout).post(PATH, fd, config);
},

/**
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/store/objectStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ export const useObjectStore = defineStore('object', () => {
};

// Actions
async function createObject(object: any, bucketId?: string) {
async function createObject(object: any, bucketId?: string, timeout?: number) {
try {
appStore.beginIndeterminateLoading();
await objectService.createObject(object, bucketId);
await objectService.createObject(object, bucketId, timeout);
}
catch (error) {
toast.add({ severity: 'error', summary: 'Error creating object', detail: error, life: 3000 });
Expand Down

0 comments on commit 12509c2

Please sign in to comment.