Skip to content

Commit

Permalink
fix:add custom x-oss-content-type(#10
Browse files Browse the repository at this point in the history
  • Loading branch information
hackycy committed Dec 9, 2020
1 parent 2e5c0c3 commit e84bda1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/utils/strategy/impl/aliyun_image_upload.dart
Expand Up @@ -30,7 +30,6 @@ class AliyunImageUpload implements ImageUploadStrategy {
@override
Future<Uploaded> upload(File file, String renameImage) async {
String configStr = await ImageUploadUtils.getPBConfig(PBTypeKeys.aliyun);
debugPrint(configStr);
if (isBlank(configStr)) {
throw AliyunError(error: '读取配置文件错误!请重试');
}
Expand All @@ -48,7 +47,9 @@ class AliyunImageUpload implements ImageUploadStrategy {
'policy': policy,
'Signature': AliyunApi.buildPostSignature(
config.accessKeyId, config.accessKeySecret, policy),
'file': await MultipartFile.fromFile(file.path, filename: renameImage)
'file': await MultipartFile.fromFile(file.path, filename: renameImage),
// OSS支持用户在Post请求体中增加x-oss-content-type,该项允许用户指定Content-Type
'x-oss-content-type': 'image/${path.extension(renameImage).replaceFirst('.', '')}'
}));
String imgPath = path.joinAll([
isBlank(config.customUrl)
Expand Down

0 comments on commit e84bda1

Please sign in to comment.