-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproguard_api.dart
More file actions
57 lines (51 loc) · 1.4 KB
/
proguard_api.dart
File metadata and controls
57 lines (51 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import 'dart:io';
import 'package:http/http.dart' as http;
Future<bool> uploadProguardMapping({
required String appId,
required String externalAccessToken,
required String path,
required String version,
required bool overwrite,
}) async {
final file = File(path);
if (!file.existsSync()) {
print('$path: file not found!');
return false;
}
print('Uploading: $path');
final url =
'https://app.raygun.com/upload/proguardsymbols/$appId?authToken=$externalAccessToken';
final request = http.MultipartRequest('POST', Uri.parse(url));
request.files.add(
http.MultipartFile(
'file',
file.readAsBytes().asStream(),
file.lengthSync(),
filename: path.split("/").last,
),
);
request.fields.addAll({
'version': version,
});
if (overwrite) {
request.fields.addAll({
'overwrite': 'true',
});
}
try {
final response = await request.send();
final responseBody = await response.stream.bytesToString();
if (response.statusCode == 200) {
print(
'Success uploading Proguard/R8 mapping file: ${response.statusCode}');
print('Result: $responseBody');
return true;
}
print('Error uploading Proguard/R8 mapping file: ${response.statusCode}');
print('Response: $responseBody');
return false;
} catch (e) {
print('Exception while uploading Proguard/R8 mapping file: $e');
return false;
}
}