http put 请求上传一个文件 flutter
http put request to upload a file flutter
如何使用 http 包在 dart 中编写 -F 获取文件而不是文件路径。
curl -X PUT "https://api.groupdocs.cloud/v1.0/parser/storage/file/hello.pdf"
-H "accept: application/json"
-H "authorization: Bearer [Access_Token]"
-H "Content-Type: multipart/form-data"
-H "x-aspose-client: Containerize.Swagger"
-F "file"="@C:/Temp/wavenet.pdf"
var headers = {
'Authorization': 'Bearer [Access_Token]'
};
var request = http.MultipartRequest('PUT', Uri.parse('https://api.groupdocs.cloud/v1.0/parser/storage/file'));
request.files.add(await http.MultipartFile.fromPath('file', '/Users/bholendraofficial/Desktop/BHOLENDRA SINGH RESUME.pdf'));
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
如何使用 http 包在 dart 中编写 -F 获取文件而不是文件路径。
curl -X PUT "https://api.groupdocs.cloud/v1.0/parser/storage/file/hello.pdf"
-H "accept: application/json"
-H "authorization: Bearer [Access_Token]"
-H "Content-Type: multipart/form-data"
-H "x-aspose-client: Containerize.Swagger"
-F "file"="@C:/Temp/wavenet.pdf"
var headers = {
'Authorization': 'Bearer [Access_Token]'
};
var request = http.MultipartRequest('PUT', Uri.parse('https://api.groupdocs.cloud/v1.0/parser/storage/file'));
request.files.add(await http.MultipartFile.fromPath('file', '/Users/bholendraofficial/Desktop/BHOLENDRA SINGH RESUME.pdf'));
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}