Commit c4352960 authored by Garfield Dai's avatar Garfield Dai

Merge branch 'chore/upload-quota' into deploy/dev

parents dada397a 5992c9cc
...@@ -134,7 +134,7 @@ const FileUploader = ({ ...@@ -134,7 +134,7 @@ const FileUploader = ({
xhr: new XMLHttpRequest(), xhr: new XMLHttpRequest(),
data: formData, data: formData,
onprogress: onProgress, onprogress: onProgress,
}) }, false, undefined, '?source=datasets')
.then((res: File) => { .then((res: File) => {
const completeFile = { const completeFile = {
fileID: fileItem.fileID, fileID: fileItem.fileID,
...@@ -146,8 +146,8 @@ const FileUploader = ({ ...@@ -146,8 +146,8 @@ const FileUploader = ({
onFileUpdate(completeFile, 100, fileListCopy) onFileUpdate(completeFile, 100, fileListCopy)
return Promise.resolve({ ...completeFile }) return Promise.resolve({ ...completeFile })
}) })
.catch(() => { .catch((e) => {
notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.failed') }) notify({ type: 'error', message: e?.response?.code === 'forbidden' ? e?.response?.message : t('datasetCreation.stepOne.uploader.failed') })
onFileUpdate(fileItem, -2, fileListCopy) onFileUpdate(fileItem, -2, fileListCopy)
return Promise.resolve({ ...fileItem }) return Promise.resolve({ ...fileItem })
}) })
......
...@@ -308,7 +308,7 @@ const baseFetch = <T>( ...@@ -308,7 +308,7 @@ const baseFetch = <T>(
]) as Promise<T> ]) as Promise<T>
} }
export const upload = (options: any, isPublicAPI?: boolean, url?: string): Promise<any> => { export const upload = (options: any, isPublicAPI?: boolean, url?: string, searchParams?: string): Promise<any> => {
const urlPrefix = isPublicAPI ? PUBLIC_API_PREFIX : API_PREFIX const urlPrefix = isPublicAPI ? PUBLIC_API_PREFIX : API_PREFIX
let token = '' let token = ''
if (isPublicAPI) { if (isPublicAPI) {
...@@ -329,7 +329,7 @@ export const upload = (options: any, isPublicAPI?: boolean, url?: string): Promi ...@@ -329,7 +329,7 @@ export const upload = (options: any, isPublicAPI?: boolean, url?: string): Promi
} }
const defaultOptions = { const defaultOptions = {
method: 'POST', method: 'POST',
url: url ? `${urlPrefix}${url}` : `${urlPrefix}/files/upload`, url: (url ? `${urlPrefix}${url}` : `${urlPrefix}/files/upload`) + (searchParams || ''),
headers: { headers: {
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment