diff --git a/frontend/src/upload/Upload.tsx b/frontend/src/upload/Upload.tsx index 0e45e8c5..e3ccad06 100644 --- a/frontend/src/upload/Upload.tsx +++ b/frontend/src/upload/Upload.tsx @@ -209,6 +209,29 @@ export default function Upload({ xhr.send(formData); }; + const uploadRemote = () => { + console.log("here") + const formData = new FormData(); + formData.append('name', urlName); + formData.append('user', 'local'); + if (urlType !== null) { + formData.append('source', urlType?.value); + } + formData.append('data', url); + const apiHost = import.meta.env.VITE_API_HOST; + const xhr = new XMLHttpRequest(); + xhr.upload.addEventListener('progress', (event) => { + const progress = +((event.loaded / event.total) * 100).toFixed(2); + setProgress({ type: 'UPLOAD', percentage: progress }); + }); + xhr.onload = () => { + const { task_id } = JSON.parse(xhr.responseText); + setProgress({ type: 'TRAINIING', percentage: 0, taskId: task_id }); + }; + xhr.open('POST', `${apiHost + '/api/remote'}`); + xhr.send(formData); + }; + const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop, multiple: false, @@ -309,12 +332,12 @@ export default function Upload({ }