question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

4.5.0 Bug: Wrong Content-Type when performing Multipart Upload Request

See original GitHub issue

Describe the bug When I upgrade the lib to 4.5.0, I always get a 413 reply from servers (I tried different servers). These servers are Peertube servers (I tried in different versions of these Peertube servers).

I downgraded the lib to 4.4.2

To Reproduce It’s not so easy as it needs to use the app at https://github.com/stom79/TubeLab/tree/update_upload Code:

Upload activity :https://github.com/stom79/TubeLab/blob/update_upload/app/src/main/java/app/fedilab/fedilabtube/PeertubeUploadActivity.java GlobalUploadObserver: https://github.com/stom79/TubeLab/blob/update_upload/app/src/main/java/app/fedilab/fedilabtube/services/GlobalUploadObserver.java Application: https://github.com/stom79/TubeLab/blob/update_upload/app/src/main/java/app/fedilab/fedilabtube/FedilabTube.java

Steps to reproduce the behavior:

  1. Create or use an account on Peertube
  2. Click on upload a video
  3. Select a video and click upload

Expected behavior Get a 200 reply from servers like I get when using 4.4.2

OS and Lib versions (please complete the following information):

  • Android Upload Service version: 4.5.0
  • Android version and API version: Android 10
  • HTTP stack: OkHttpStack

Request code:

new MultipartUploadRequest(PeertubeUploadActivity.this, "https://" + Helper.getLiveInstance(PeertubeUploadActivity.this) + "/api/v1/videos/upload")
                            .setMethod("POST")
                            .setBearerAuth(token)
                            .addHeader("User-Agent", getString(R.string.app_name) + "/" + BuildConfig.VERSION_NAME)
                            .addParameter("privacy", String.valueOf(idPrivacy))
                            .addParameter("nsfw", "false")
                            .addParameter("name", filename)
                            .addParameter("commentsEnabled", "true")
                            .addParameter("downloadEnabled", "true")
                            .addParameter("waitTranscoding", "true")
                            .addParameter("channelId", idChannel)
                            .addFileToUpload(uri.toString(), "videofile")
                            .setNotificationConfig((context, uploadId) -> getNotificationConfig(uploadId))
                            .setMaxRetries(2)
                            .startUpload();

Where have you added the request code?

  • Activity
  • Service
  • Other class (add additional info about it)

Debug Log:

MultipartUploadTask - (uploadId: 982d1af5-8b54-419a-a59d-1098ac9f44c6) - Server response: code 413, body 
2020-11-21 09:36:49.520 27553-31691/app.fedilab.tubelab I/UploadService: UploadTask - (uploadId: 982d1af5-8b54-419a-a59d-1098ac9f44c6) - upload error
2020-11-21 09:36:49.555 27553-27553/app.fedilab.tubelab W/System.err: net.gotev.uploadservice.exceptions.UploadError: Upload error
2020-11-21 09:36:49.556 27553-27553/app.fedilab.tubelab W/System.err:     at net.gotev.uploadservice.UploadTask.onResponseReceived(UploadTask.kt:237)
2020-11-21 09:36:49.556 27553-27553/app.fedilab.tubelab W/System.err:     at net.gotev.uploadservice.HttpUploadTask.upload(HttpUploadTask.kt:65)
2020-11-21 09:36:49.557 27553-27553/app.fedilab.tubelab W/System.err:     at net.gotev.uploadservice.UploadTask.run(UploadTask.kt:144)
2020-11-21 09:36:49.557 27553-27553/app.fedilab.tubelab W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2020-11-21 09:36:49.557 27553-27553/app.fedilab.tubelab W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2020-11-21 09:36:49.557 27553-27553/app.fedilab.tubelab W/System.err:     at java.lang.Thread.run(Thread.java:919)

From server:

{"message":"xx.xx.xx.xx - - [20/Nov/2020:17:37:07 +0000] \"POST /api/v1/videos/upload HTTP/1.1\" 413 - \"-\" \"Tubelab/fdroid_full\"\n","level":"info","label":"example.com:443","timestamp":"2020-11-20T17:37:07.396Z"}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
gotevcommented, Nov 22, 2020

@stom79 released 4.5.1 with the fix. Remove the manual addHeader and your uploads should behave correctly again 😉

0reactions
gotevcommented, Nov 22, 2020

@stom79 you’re welcome and thank you for supporting the project 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP Module using wrong Content-Type for multipart/form-data
In my case, my "Content-Type": "multipart/formdata" header is overwritten by "Content-Type": "application/json" . This causes backend to parse ...
Read more >
WebAPI cannot parse multipart/form-data post - Stack Overflow
Here is exact error: Unexpected end of MIME multipart stream. MIME multipart message is not complete." It fails here: await Request.Content.
Read more >
Uploading and copying objects using multipart upload
Multipart upload allows you to upload a single object as a set of parts. Each part is a contiguous portion of the object's...
Read more >
Changelog - Cypress Documentation
Fixed a bug where the cypress/svelte cy.mount() command was not logging by ... Fixes #9040. multipart/form-data is no longer wrongly encoded when using ......
Read more >
cgi — Common Gateway Interface support ... - Python Docs
Parse input of type multipart/form-data (for file uploads). Arguments are fp for the input file, pdict for a dictionary containing other parameters in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found