uploadSymbols function
Implementation
Future<bool> uploadSymbols({
required String appId,
required String token,
required String path,
required String version,
}) async {
final file = File(path);
if (!file.existsSync()) {
print('$path: file not found!');
return false;
}
print('Uploading: $path');
final url = 'https://api.raygun.com/v3/applications/$appId/flutter-symbols';
final request = http.MultipartRequest('PUT', Uri.parse(url));
request.headers.addAll({
'Authorization': 'Bearer $token',
'Content-Type': 'multipart/form-data',
});
request.files.add(
http.MultipartFile(
'file',
file.readAsBytes().asStream(),
file.lengthSync(),
filename: path.split("/").last,
),
);
request.fields.addAll({
'version': version,
});
final res = await request.send();
if (res.statusCode == 200) {
print('File uploaded succesfully!');
return true;
} else {
print('Error uploading file. Response code: ${res.statusCode}');
return false;
}
}