@@ -19,6 +19,7 @@ const Title = styled.h2`
19
19
20
20
const Input = styled . input `
21
21
width: 100%;
22
+ box-sizing: border-box;
22
23
padding: 12px;
23
24
margin: 10px 0;
24
25
border: 1px solid #ccc;
@@ -50,34 +51,28 @@ function UploadPage() {
50
51
const [ bucketName , setBucketName ] = useState ( "" ) ;
51
52
const [ fileName , setFileName ] = useState ( "" ) ;
52
53
53
- const handleFileChange = ( e ) => {
54
- setFile ( e . target . files [ 0 ] ) ;
55
- } ;
56
-
57
54
const handleUpload = async ( ) => {
58
- if ( ! file || ! bucketName || ! fileName ) {
59
- alert ( "Please fill in all fields" ) ;
60
- return ;
61
- }
62
-
63
55
const formData = new FormData ( ) ;
64
56
formData . append ( "file" , file ) ;
65
57
formData . append ( "bucketName" , bucketName ) ;
66
58
formData . append ( "fileName" , fileName ) ;
67
59
68
60
try {
69
- const response = await axios . post ( "/file-transfer/upload" , formData ) ;
70
- alert ( response . data ) ;
61
+ await axios . post ( "/file-transfer/upload" , formData ) ;
62
+ alert ( "File uploaded to S3 successfully!" ) ;
71
63
} catch ( error ) {
72
- console . error ( "Error uploading file:" , error ) ;
73
- alert ( "Failed to upload the file." ) ;
64
+ alert ( "Error uploading file to S3." ) ;
74
65
}
75
66
} ;
76
67
77
68
return (
78
69
< Card >
79
70
< Title > Upload to S3</ Title >
80
- < Input type = "file" onChange = { handleFileChange } />
71
+ < input
72
+ type = "file"
73
+ onChange = { ( e ) => setFile ( e . target . files [ 0 ] ) }
74
+ required
75
+ />
81
76
< Input
82
77
type = "text"
83
78
placeholder = "Bucket Name"
0 commit comments