From ed1d35b5394136bde5e13e854c60b00034794523 Mon Sep 17 00:00:00 2001 From: Matthieu <24-artectrex@users.noreply.shinice.net> Date: Mon, 25 Jan 2021 18:54:55 +0100 Subject: [PATCH] Fix media descriptions being wrapped with string --- .../com/h/pixeldroid/postCreation/PostCreationActivity.kt | 6 +++++- app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/h/pixeldroid/postCreation/PostCreationActivity.kt b/app/src/main/java/com/h/pixeldroid/postCreation/PostCreationActivity.kt index 1618f084..a3052b95 100644 --- a/app/src/main/java/com/h/pixeldroid/postCreation/PostCreationActivity.kt +++ b/app/src/main/java/com/h/pixeldroid/postCreation/PostCreationActivity.kt @@ -284,7 +284,11 @@ class PostCreationActivity : BaseActivity() { } var postSub: Disposable? = null - val inter = pixelfedAPI.mediaUpload("Bearer $accessToken", data.imageDescription, requestBody.parts[0]) + + val description = data.imageDescription?.let { MultipartBody.Part.createFormData("description", it) } + + + val inter = pixelfedAPI.mediaUpload("Bearer $accessToken", description, requestBody.parts[0]) postSub = inter .subscribeOn(Schedulers.io()) diff --git a/app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt b/app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt index d79392b8..e92a1ee0 100644 --- a/app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt +++ b/app/src/main/java/com/h/pixeldroid/utils/api/PixelfedAPI.kt @@ -256,7 +256,7 @@ interface PixelfedAPI { fun mediaUpload( //The authorization header needs to be of the form "Bearer " @Header("Authorization") authorization: String, - @Part("description") description: String?, + @Part description: MultipartBody.Part? = null, @Part file: MultipartBody.Part ): Observable