-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* send a file with smbclient * upgrade fastapi * add python-multipart * upgrade dev deps * fix fastapi * fix ruff args * Add TMP_PATH to config.py
- Loading branch information
1 parent
90a3e0d
commit bd00961
Showing
10 changed files
with
734 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<script lang="ts"> | ||
import axios from 'axios'; | ||
import { BACKEND_URL } from '$lib/constants/backend'; | ||
import { Content, FileUploader, ToastNotification } from 'carbon-components-svelte'; | ||
import { _ } from 'svelte-i18n'; | ||
let updateSuccess = false; | ||
let error: string | null = null; | ||
const handleFileChange = async (event: CustomEvent) => { | ||
console.log(event); | ||
const fileInput = event.detail; | ||
if (fileInput === null) return; | ||
const file = fileInput[0]; | ||
if (!file) return; | ||
const formData = new FormData(); | ||
formData.append('file', file); | ||
try { | ||
const res = await axios.post(`${BACKEND_URL}/send/file`, formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
}); | ||
console.log(res); | ||
if (res.status === 200 && res.data['status'] === 'ok') { | ||
updateSuccess = true; | ||
} else { | ||
error = res.data['message']; | ||
} | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; | ||
</script> | ||
|
||
<Content> | ||
<div id="file-uploader"> | ||
<FileUploader | ||
labelTitle={$_('menu.sendFile')} | ||
buttonLabel={$_('home.upload3dmodel.buttonLabel')} | ||
status="complete" | ||
on:change={handleFileChange} | ||
/> | ||
</div> | ||
|
||
{#if updateSuccess} | ||
<ToastNotification | ||
kind="success" | ||
title={$_('common.sendSuccess')} | ||
timeout={3000} | ||
on:close={() => (updateSuccess = false)} | ||
/> | ||
{/if} | ||
|
||
{#if error} | ||
<ToastNotification | ||
kind="error" | ||
title={$_('common.sendFailed')} | ||
subtitle={error} | ||
timeout={3000} | ||
on:close={() => (error = null)} | ||
/> | ||
{/if} | ||
</Content> | ||
|
||
<style> | ||
#file-uploader { | ||
margin: 1rem; | ||
} | ||
</style> |