我需要转换以下 cURL 命令:
curl --request PUT \
--url https://storage.bunnycdn.com/storage/path/index.jpeg \
--header 'AccessKey: <AccessKey>' \
--header 'Content-Type: application/octet-stream' \
--data-binary @/home/path/to/index.jpeg
它发送一个 put 请求,其中包含要上传到 CDN 的图像
到 https put 请求,特别是使用--data-binary
我试过了 :
try {
var request = new http.MultipartRequest("PUT", uri);
request.headers.addAll({
'content-type': 'multipart/form-data',
'AccessKey': '<AccessKey>',
});
request.files.add(
await http.MultipartFile.fromPath(
'file',
_image.path,
filename: fileName,
),
);
var response = request.send().then((value) => setState(() {
isLoading = false;
}));
} catch (e) {
print(e);
}
但不幸的是,该文件以错误的格式到达 CDN 存储。
如何使用 http put 请求作为--data-binary上传图像