@@ -96,7 +96,8 @@ class UploadSoFilesCommand {
96
96
97
97
// Validate architecture
98
98
if (! validArchs.contains (options.arch)) {
99
- print ('[Instabug-CLI] Error: Invalid architecture: ${options .arch }. Valid options: ${validArchs .join (', ' )}' );
99
+ print (
100
+ '[Instabug-CLI] Error: Invalid architecture: ${options .arch }. Valid options: ${validArchs .join (', ' )}' );
100
101
throw Exception (
101
102
'Invalid architecture: ${options .arch }. Valid options: ${validArchs .join (', ' )}' );
102
103
}
@@ -106,31 +107,44 @@ class UploadSoFilesCommand {
106
107
print ('File: ${options .file }' );
107
108
print ('App Version: ${options .name }' );
108
109
109
- // TODO: Implement the actual upload logic here
110
- // This would typically involve:
111
- // 1. Reading the zip file
112
- // 2. Making an HTTP request to the upload endpoint
113
- // 3. Handling the response
114
-
115
- // Make an HTTP request to the upload endpoint
116
- final body = {
117
- 'arch' : options.arch,
118
- 'api_key' : options.apiKey,
119
- 'application_token' : options.token,
120
- 'so_file' : options.file,
121
- 'app_version' : options.name,
122
- };
123
-
124
110
const endPoint = 'https://api.instabug.com/api/web/public/so_files' ;
125
111
126
- final response = await makeHttpPostRequest (
127
- url: endPoint,
128
- body: body,
112
+ // Create multipart request
113
+ final request = http.MultipartRequest ('POST' , Uri .parse (endPoint));
114
+
115
+ // Add form fields
116
+ request.fields['arch' ] = options.arch;
117
+ request.fields['api_key' ] = options.apiKey;
118
+ request.fields['application_token' ] = options.token;
119
+ request.fields['app_version' ] = options.name;
120
+
121
+ // Add the zip file
122
+ final fileStream = http.ByteStream (file.openRead ());
123
+ final fileLength = await file.length ();
124
+ final multipartFile = http.MultipartFile (
125
+ 'so_file' ,
126
+ fileStream,
127
+ fileLength,
128
+ filename: file.path.split ('/' ).last,
129
129
);
130
+ request.files.add (multipartFile);
131
+
132
+ final response = await request.send ();
133
+
134
+ if (response.statusCode < 200 || response.statusCode >= 300 ) {
135
+ final responseBody = await response.stream.bytesToString ();
136
+ print ('[Instabug-CLI] Error: Failed to upload .so files' );
137
+ print ('Status Code: ${response .statusCode }' );
138
+ print ('Response: $responseBody ' );
139
+ exit (1 );
140
+ }
130
141
131
- print ('Successfully uploaded .so files for version: ${options .name } with arch ${options .arch }' );
142
+ print (
143
+ 'Successfully uploaded .so files for version: ${options .name } with arch ${options .arch }' );
144
+ exit (0 );
132
145
} catch (e) {
133
- print ('[Instabug-CLI] Error: Error uploading .so files: $e ' );
146
+ print ('[Instabug-CLI] Error uploading .so files, $e ' );
147
+ print ('[Instabug-CLI] Error Stack Trace: ${StackTrace .current }' );
134
148
exit (1 );
135
149
}
136
150
}
0 commit comments