uploadFile method
Implementation
@override
Future<Map> uploadFile(
String token, String environment, String? notes, File file) async {
String addNotes = notes != null ? "?notes=$notes" : "";
String baseUrl = environment == "demo"
? "https://files-demo.airwallex.com"
: "https://files.airwallex.com";
var url = Uri.parse("$baseUrl/api/v1/files/upload$addNotes");
var request = http.MultipartRequest('POST', url);
request.fields['file'] = 'Folder';
request.headers['Authorization'] = "Bearer $token";
final toUploadFile = await http.MultipartFile.fromPath('file', file.path);
request.files.add(toUploadFile);
var response = await request.send();
var responseData = await response.stream.toBytes();
String stringData = String.fromCharCodes(responseData);
var data = jsonDecode(stringData);
return data;
}