in the post I send the bytes
Future<dynamic> postHttpFile(String table,dynamic image,String userToken) async {
String url = env.URL + table;
final urlFinal = Uri.parse(url);
Map<String, String> headers = {
'Content-Type': 'multipart/form-data',
'Authorization': 'Bearer ' + userToken
};
var request = http.MultipartRequest("POST", urlFinal);
var multipartFileSign = http.MultipartFile.fromBytes('upload', image,);
request.files.add(multipartFileSign);
request.headers.addAll(headers);
var response = await request.send();
//var responseData = await response.stream.bytesToString();
var res = await http.Response.fromStream(response);
inspect(res);
return res;
}
in the inspect I receive this...
bodyBytes:NativeUint8List ([123, 34, 102, 105, 108, 101, 115, 34, 58, 91, 93, 125]) contentLength:12 headers:Map (2 items) isRedirect:false persistentConnection:true reasonPhrase:"OK" request:MultipartRequest (POST https://**********/contacts/uploadAvatar) statusCode:200in return i get this..
Instance of 'Response'
I need the URL
You should try this.
var multipartFileSign = http.MultipartFile.fromPath('upload', image.path,);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.