Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultipartFormDataUpload does not work as expected same as old version #162

Open
huynguyennovem opened this issue May 9, 2021 · 1 comment
Labels
android Android-only issues bug Something isn't working

Comments

@huynguyennovem
Copy link

I tried to upgrade the latest version from 1.2.1 to 3.0.0-beta.1 same as below:

  • Old:
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:
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, but the same error.
Does anyone have an idea for this?

@ened
Copy link
Collaborator

ened commented May 28, 2021

There seems to be a unexpected end of stream. Are you able to reproduce this in the example project?

@ened ened added android Android-only issues bug Something isn't working labels May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Android-only issues bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants