File tree Expand file tree Collapse file tree 3 files changed +36
-10
lines changed Expand file tree Collapse file tree 3 files changed +36
-10
lines changed Original file line number Diff line number Diff line change 1
- import 'dart:developer' ;
2
- import 'dart:io' ;
3
- import 'package:args/args.dart' ;
4
- import 'package:http/http.dart' as http;
1
+ part of '../instabug.dart' ;
5
2
6
3
/**
7
4
* This script uploads .so files to the specified endpoint used in NDK crash reporting.
8
- * Usage: dart instabug.dart upload-so-files --arch <arch> --file <path> --api_key <key> --token <token> --name <name>
5
+ * Usage: dart run instabug_flutter: instabug upload-so-files --arch <arch> --file <path> --api_key <key> --token <token> --name <name>
9
6
*/
10
7
11
8
class UploadSoFilesOptions {
@@ -126,8 +123,8 @@ class UploadSoFilesCommand {
126
123
127
124
const endPoint = 'https://api.instabug.com/api/web/public/so_files' ;
128
125
129
- final response = await http. post (
130
- Uri . parse ( endPoint) ,
126
+ final response = await makeHttpPostRequest (
127
+ url : endPoint,
131
128
body: body,
132
129
);
133
130
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env dart
2
2
3
- import 'dart:developer ' ;
3
+ import 'dart:convert ' ;
4
4
import 'dart:io' ;
5
5
6
6
import 'package:args/args.dart' ;
7
7
8
- import 'commands/upload_so_files.dart' ;
8
+ part 'commands/upload_so_files.dart' ;
9
9
10
10
// Command registry for easy management
11
11
class CommandRegistry {
@@ -27,6 +27,36 @@ class CommandHandler {
27
27
CommandHandler ({required this .parser, required this .execute});
28
28
}
29
29
30
+ Future <bool > makeHttpPostRequest ({
31
+ required String url,
32
+ required Map <String , String > body,
33
+ Map <String , String >? headers,
34
+ }) async {
35
+ try {
36
+ final client = HttpClient ();
37
+
38
+ final request = await client.postUrl (Uri .parse (url));
39
+
40
+ request.headers.contentType = ContentType .json;
41
+
42
+ request.write (jsonEncode (body));
43
+
44
+ final response = await request.close ();
45
+
46
+ if (response.statusCode >= 200 && response.statusCode < 300 ) {
47
+ final responseBody = await response.transform (utf8.decoder).join ();
48
+ return true ;
49
+ } else {
50
+ print ('Error: ${response .statusCode }' );
51
+ return false ;
52
+ }
53
+
54
+ } catch (e) {
55
+ print ('[Instabug-CLI] Error while making HTTP POST request: $e ' );
56
+ exit (1 );
57
+ }
58
+ }
59
+
30
60
void main (List <String > args) async {
31
61
final parser = ArgParser ()..addFlag ('help' , abbr: 'h' );
32
62
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ dependencies:
11
11
args : ^2.4.0
12
12
flutter :
13
13
sdk : flutter
14
- http : ^0.13.6
15
14
meta : ^1.3.0
16
15
stack_trace : ^1.10.0
17
16
You can’t perform that action at this time.
0 commit comments