Flutter Retorfit 上传时多部分中的可变图像类型

问题描述 投票:0回答:1

目前我正在使用 retrofit.dartDio 将图像上传为多部分文件。

userImage = File(/*image path*/);
uploadProfileImage(userImage);

网络服务功能

@POST(AppURLs.editProfileImage)
@MultiPart()
Future<NetworkBaseModel<UserResponseModel>> editProfileImageAPI(
    @Part(contentType: 'image/jpeg') File profileImage,
);

这个效果很好。但是,正如您在@Part注释中看到的,图像类型固定为'image/jpeg'...

我想要的是一种根据所选图像扩展名动态更改此类型的方法。

有办法做到吗??

flutter dart retrofit2 dio
1个回答
0
投票

你找到答案了吗?

© www.soinside.com 2019 - 2024. All rights reserved.