Comments (6)
Yes I've already tried your solution and it works.
Meanwhile I found a workaround on my code:
dio.MultipartFile.fromBytes(
Uint8List.fromList(fileData),
filename: fileName,
contentType: contentType,
),
Thanks @AlexV525!
from dio.
Huge thanks for your inputs!
from dio.
I think is related to:
I suppose the problem is in form_data.dart
:
final controller = StreamController<Uint8List>(sync: false);
...
Future<void>(() async {
for (final file in files) {
writeUtf8('--$boundary$_rn');
writeUtf8(_headerForFile(file));
await writeStreamToSink(file.value.finalize(), controller);
writeLine();
}
}).then((_) {
writeUtf8('--$boundary--$_rn');
}).whenComplete(() {
controller.close();
});
multipart_file.dart
Stream<List<int>> finalize();
Calling writeStreamToSink(Stream<List<int>>, StreamController<Uint8List>)
throws a TypeError
because is trying to add List<int>
to a Uint8List
sink.
from dio.
@fromlabs Could you try updating the implementation to below solve the problem?
Future<void>(() async {
for (final file in files) {
writeUtf8('--$boundary$_rn');
writeUtf8(_headerForFile(file));
await writeStreamToSink<Uint8List>(
file.value
.finalize()
.map((e) => e is Uint8List ? e : Uint8List.fromList(e)),
controller,
);
writeLine();
}
}).then((_) {
writeUtf8('--$boundary--$_rn');
}).whenComplete(() {
controller.close();
});
from dio.
@fromlabs Are you able to extract a minimal reproducible example? I'm wondering why the issue (if it exists) escapes from our tests.
from dio.
I think because formdata_test.dart
doesn't test directly MultipartFile.fromBytes
with real List<int>
, but tests just MultipartFile.fromString
, MultipartFile.fromFile
and MultipartFile.fromFileSync
which work under the hood with Uint8List
.
from dio.
Related Issues (20)
- FormData and List of Int not working as expected. HOT 2
- flutter dynamic coockies management HOT 1
- post请求超时无反应 HOT 1
- Error Dio flutter web HOT 1
- upload file send timeout
- Header is out of order HOT 3
- `ResponseType.stream` is not working on web. HOT 1
- [🔔 Dio] sendTimeout cannot be used without a request body to send HOT 2
- `Transformer.isJsonMimeType` throws format exceptions without caught
- onError is not returning any error HOT 3
- Error when uploading image using MultipartFile.fromBytes in version 5.4.3+1 HOT 1
- 为什么dio的fromMap会将MultipartFile自动放入files字段中 HOT 1
- Error: The method 'debugLog' isn't defined for the class 'BrowserHttpClientAdapter'. HOT 1
- Version 5.5.0 brakes the web build HOT 1
- Is it now possible to use DIO / dio_web_adapter with Web/WASM? HOT 41
- Dio 5.5 broke compilation for WASM HOT 6
- ResponseType.stream returns responce all at once on Web HOT 1
- Date header not parsed correctly HOT 1
- set proxy for BrowserHttpClientAdapter HOT 1
- Dio fetch can't catch error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dio.