@@ -27,11 +27,9 @@ pub async fn handle_file_upload(
27
27
wallet : & Arc < Wallet > ,
28
28
state : & Arc < SystemState > ,
29
29
) -> Result < ( ) > {
30
- println ! ( "Starting file upload handler..." ) ;
31
30
info ! ( "📄 Received file upload request: {}" , file_name) ;
32
31
33
32
// Get orchestrator endpoint
34
- println ! ( "Getting orchestrator endpoint..." ) ;
35
33
let endpoint = state
36
34
. get_heartbeat_endpoint ( )
37
35
. await
@@ -40,19 +38,15 @@ pub async fn handle_file_upload(
40
38
anyhow:: anyhow!( "Orchestrator endpoint not set" )
41
39
} ) ?
42
40
. replace ( "/heartbeat" , "" ) ;
43
- println ! ( "Got endpoint: {}" , endpoint) ;
44
41
45
42
// Construct file path
46
43
let file = format ! ( "{}/prime-task-{}/{}" , storage_path, task_id, file_name) ;
47
- println ! ( "Constructed file path: {}" , file) ;
48
44
debug ! ( "File: {:?}" , file) ;
49
45
50
46
// Get file size
51
- println ! ( "Getting file size..." ) ;
52
47
let file_size = std:: fs:: metadata ( & file) . map ( |m| m. len ( ) ) . unwrap_or ( 0 ) ;
53
48
54
49
// Calculate SHA
55
- println ! ( "Calculating file SHA..." ) ;
56
50
let file_sha = tokio:: fs:: read ( & file)
57
51
. await
58
52
. map ( |contents| {
@@ -68,10 +62,8 @@ pub async fn handle_file_upload(
68
62
69
63
debug ! ( "File size: {:?}" , file_size) ;
70
64
debug ! ( "File SHA: {}" , file_sha) ;
71
- println ! ( "File size: {}, SHA: {}" , file_size, file_sha) ;
72
65
73
66
// Create upload request
74
- println ! ( "Creating upload request..." ) ;
75
67
let client = Client :: new ( ) ;
76
68
let request = RequestUploadRequest {
77
69
file_name : file_sha. to_string ( ) ,
@@ -80,15 +72,12 @@ pub async fn handle_file_upload(
80
72
} ;
81
73
82
74
// Sign request
83
- println ! ( "Signing request..." ) ;
84
75
let request_value = serde_json:: to_value ( & request) ?;
85
76
let signature = sign_request ( "/storage/request-upload" , wallet, Some ( & request_value) )
86
77
. await
87
78
. map_err ( |e| anyhow:: anyhow!( e. to_string( ) ) ) ?;
88
- println ! ( "Request signed with signature: {}" , signature) ;
89
79
90
80
// Prepare headers
91
- println ! ( "Preparing request headers..." ) ;
92
81
let mut headers = reqwest:: header:: HeaderMap :: new ( ) ;
93
82
headers. insert (
94
83
"x-address" ,
@@ -98,48 +87,38 @@ pub async fn handle_file_upload(
98
87
99
88
// Create upload URL
100
89
let upload_url = format ! ( "{}/storage/request-upload" , endpoint) ;
101
- println ! ( "Upload URL: {}" , upload_url) ;
102
90
103
91
// Send request
104
- println ! ( "Sending request to get signed URL..." ) ;
105
92
let response = client
106
93
. post ( & upload_url)
107
94
. json ( & request)
108
95
. headers ( headers)
109
96
. send ( )
110
97
. await ?;
111
98
112
- println ! ( "Response: {:?}" , response) ;
113
99
// Process response
114
100
let json = response. json :: < serde_json:: Value > ( ) . await ?;
115
- println ! ( "Response JSON: {:?}" , json) ;
116
101
117
102
if let Some ( signed_url) = json[ "signed_url" ] . as_str ( ) {
118
103
info ! ( "Got signed URL for upload: {}" , signed_url) ;
119
- println ! ( "Got signed URL: {}" , signed_url) ;
120
104
121
105
// Read file contents
122
- println ! ( "Reading file contents..." ) ;
123
106
let file_contents = tokio:: fs:: read ( & file) . await ?;
124
- println ! ( "File contents size: {} bytes" , file_contents. len( ) ) ;
125
107
126
108
// Upload file to S3 using signed URL
127
- println ! ( "Uploading file to S3..." ) ;
128
109
let upload_response = client
129
110
. put ( signed_url)
130
111
. body ( file_contents)
131
112
. header ( "Content-Type" , "application/json" )
132
113
. send ( )
133
114
. await ?;
134
115
135
- println ! ( "S3 upload response: {:?}" , upload_response) ;
136
116
info ! ( "Successfully uploaded file to S3" ) ;
137
117
} else {
138
118
println ! ( "Error: Missing signed_url in response" ) ;
139
119
return Err ( anyhow:: anyhow!( "Missing signed_url in response" ) ) ;
140
120
}
141
121
142
- println ! ( "File upload completed successfully" ) ;
143
122
Ok ( ( ) )
144
123
}
145
124
0 commit comments