11import React , { useState } from "react" ;
22import "./App.css" ;
33
4- import {
5- OpenFileSelectionDialog ,
6- OpenMultipleFilesSelectionDialog ,
7- } from "../wailsjs/go/main/App" ;
4+ import { OpenFileSelectionDialog , UploadFile } from "../wailsjs/go/main/App" ;
85
96function App ( ) {
107 const [ selectedFilePath , setSelectedFilePath ] = useState < string > ( "" ) ;
@@ -26,27 +23,14 @@ function App() {
2623 }
2724 } ;
2825
29- const handleOpenMultipleFiles = async ( ) => {
30- setError ( "" ) ;
31- try {
32- const paths = await OpenMultipleFilesSelectionDialog ( ) ;
33- if ( paths && paths . length > 0 ) {
34- setSelectedFilePaths ( paths ) ;
35- } else {
36- setSelectedFilePaths ( [ "No files selected." ] ) ;
37- }
38- } catch ( err : any ) {
39- setError (
40- `Error opening multiple files dialog: ${ err . message || String ( err ) } ` ,
41- ) ;
42- setSelectedFilePaths ( [ "Error!" ] ) ;
43- }
26+ const handleUpload = async ( ) => {
27+ UploadFile ( [ selectedFilePath ] ) ;
4428 } ;
4529
4630 return (
4731 < div className = "App" >
4832 < header className = "App-header" >
49- < h1 > Wails File Dialog Demo </ h1 >
33+ < h1 > Wails Fileshare Client </ h1 >
5034
5135 { error && < p style = { { color : "red" } } > { error } </ p > }
5236
@@ -56,10 +40,7 @@ function App() {
5640 </ div >
5741
5842 < div className = "card" >
59- < button onClick = { handleOpenMultipleFiles } >
60- Open Multiple Files Dialog
61- </ button >
62- < p > Selected Files: { selectedFilePaths . join ( ", " ) } </ p >
43+ < button onClick = { handleUpload } > Upload This File</ button >
6344 </ div >
6445 </ header >
6546 </ div >
0 commit comments