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

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"}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

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