postFileByFormData method
dynamic
postFileByFormData({})
使用 form 表单传递文件
Implementation
postFileByFormData(
{required String url,
required String? filePath,
required Map<String, dynamic> metadata,
void onProcess(int count, int total)?}) async {
if (filePath == null) {
throw new CloudBaseException(
code: CloudBaseExceptionCode.EMPTY_PARAM,
message: 'filePath cloud not be empty');
}
print(filePath);
Map<String, dynamic> data = {};
data.addAll(metadata);
data.addAll({"file": await MultipartFile.fromFile(filePath)});
FormData formData = FormData.fromMap(data);
await _dio.post(url, data: formData, onSendProgress: onProcess);
}