fluttercommunity / fluttercommunity/flutter_uploader
MultipartFormDataUpload does not work as expected same as old version
- Dominant language
- Dart
- Stars
- 218
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
I tried to upgrade the latest version from `1.2.1` to `3.0.0-beta.1` same as below:
- Old:
```dart
await _uploader.enqueue(
url: url,
files: [
FileItem(savedDir: fileInfo.filePath, filename: fileInfo.fileName)
],
headers: {
Constant.authorization: 'Bearer ${token.token}',
Constant.accept: 'application/json',
},
data: {
Constant.fileSizeDataForm: (await file.length()).toString()
}
)
```
**-> Result: Upload successfully**
- New:
```dart
final file = File(fileInfo.filePath + fileInfo.fileName); // make sure the output will be: /data/..../abc.png
await _uploader.enqueue(
MultipartFormDataUpload(
url: url,
files: [
FileItem(path: file.path, field: 'file')
],
headers: {
Constant.authorization: 'Bearer ${token.token}',
Constant.accept: 'application/json',
},
data: {
Constant.fileSizeDataForm: (await file.length()).toString()
}
)
)
```
**-> Result: Upload fail with error log:**
```
E/UploadWorker(26371): exception encounteredprotocol
E/UploadWorker(26371): java.net.ProtocolException: unexpected end of stream
E/UploadWorker(26371): at okhttp3.internal.connection.Exchange$RequestBodySink.close(Exchange.kt:239)
E/UploadWorker(26371): at okio.RealBufferedSink.close(RealBufferedSink.kt:268)
E/UploadWorker(26371): at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:60)
E/UploadWorker(26371): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
E/UploadWorker(26371): at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
E/UploadWorker(26371): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
E/UploadWorker(26371): at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
E/UploadWorker(26371): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
E/UploadWorker(26371): at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
E/UploadWorker(26371): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
E/UploadWorker(26371): at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
E/UploadWorker(26371): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
E/UploadWorker(26371): at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
E/UploadWorker(26371): at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
E/UploadWorker(26371): at com.bluechilli.flutteruploader.UploadWorker.doWorkInternal(UploadWorker.java:253)
E/UploadWorker(26371): at com.bluechilli.flutteruploader.UploadWorker.lambda$null$0$UploadWorker(UploadWorker.java:98)
E/UploadWorker(26371): at com.bluechilli.flutteruploader.-$$Lambda$UploadWorker$Ho59XPh0Nv1qDklSXHWeL_QPIl0.run(Unknown Source:4)
E/UploadWorker(26371): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/UploadWorker(26371): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/UploadWorker(26371): at java.lang.Thread.run(Thread.java:764)
```
I have tried the solution from [#2738](https://github.com/square/okhttp/issues/2738), but the same error.
Does anyone have an idea for this?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.