Open Yogesh070 opened 5 months ago
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior: I have defined the api as:
@POST('') Future saveProfileGreetings( @Part() File file, @Part() String link, @SendProgress() ProgressCallback onSendProgress, );
This works fine but I want to assign content type on MultipartFile by looking up mime type.
Expected behavior I want to generate the api as the following where i can set content type as :
contentType: MediaType.parse(lookupMimeType(file.path)!),
@override Future saveProfileGreetings( File file, String link, void Function(int, int) onSendProgress, ) async { final _extra = <String, dynamic>{}; final queryParameters = <String, dynamic>{}; final _headers = <String, dynamic>{}; final _data = FormData(); _data.files.add(MapEntry( 'file', MultipartFile.fromFileSync( file.path, filename: file.path.split(Platform.pathSeparator).last, contentType: MediaType.parse(lookupMimeType(file.path)!), ), )); _data.fields.add(MapEntry( 'link', link, )); await _dio.fetch(_setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, contentType: 'multipart/form-data', ) .compose( _dio.options, '', queryParameters: queryParameters, data: _data, onSendProgress: onSendProgress, ) .copyWith( baseUrl: _combineBaseUrls( _dio.options.baseUrl, baseUrl, )))); }
Additional context Add any other context about the problem here.
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior: I have defined the api as:
@POST('') Future saveProfileGreetings(
@Part() File file,
@Part() String link,
@SendProgress() ProgressCallback onSendProgress,
);
This works fine but I want to assign content type on MultipartFile by looking up mime type.
Expected behavior I want to generate the api as the following where i can set content type as :
@override Future saveProfileGreetings(
File file,
String link,
void Function(int, int) onSendProgress,
) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
final _data = FormData();
_data.files.add(MapEntry(
'file',
MultipartFile.fromFileSync(
file.path,
filename: file.path.split(Platform.pathSeparator).last,
contentType: MediaType.parse(lookupMimeType(file.path)!),
),
));
_data.fields.add(MapEntry(
'link',
link,
));
await _dio.fetch(_setStreamType(Options(
method: 'POST',
headers: _headers,
extra: _extra,
contentType: 'multipart/form-data',
)
.compose(
_dio.options,
'',
queryParameters: queryParameters,
data: _data,
onSendProgress: onSendProgress,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
))));
}
Additional context Add any other context about the problem here.