upload method
Implementation
Future<Map<String, dynamic>> upload(
String filePath, String type, FileTypeCobe fileType) async {
var contentType;
switch (fileType) {
case FileTypeCobe.image:
contentType = MediaType('image', 'jpeg');
break;
case FileTypeCobe.video:
contentType = MediaType('video', 'mp4');
break;
default:
contentType = MediaType('image', 'jpeg');
break;
}
var request = http.MultipartRequest('POST', Uri.parse(COBEFILE_URL));
request.files.add(await http.MultipartFile.fromPath('files', filePath,
contentType: contentType));
request.fields['type'] = type;
request.headers['Access-Control-Allow-Origin'] = '*';
request.headers['Authorization'] = 'amx ' + _sign();
request.headers['Cache-Control'] = 'no-cache';
var response = await request.send();
var responseBody = await response.stream.bytesToString();
return json.decode(responseBody);
}