diff --git a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/mastodon/api/MediaResources.java b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/mastodon/api/MediaResources.java index 42c3f6fce..56d762255 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/microblog/library/mastodon/api/MediaResources.java +++ b/twidere.component.common/src/main/java/org/mariotaku/microblog/library/mastodon/api/MediaResources.java @@ -18,6 +18,8 @@ package org.mariotaku.microblog.library.mastodon.api; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.mariotaku.microblog.library.MicroBlogException; import org.mariotaku.microblog.library.mastodon.model.Attachment; import org.mariotaku.restfu.annotation.method.POST; @@ -33,6 +35,7 @@ public interface MediaResources { @POST("/v1/media") @BodyType(BodyType.MULTIPART) - Attachment uploadMediaAttachment(@Param("file") Body body) throws MicroBlogException; + Attachment uploadMediaAttachment(@NonNull @Param("file") Body body, + @Nullable @Param("description") String description) throws MicroBlogException; } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt index 911c64f69..941acf52f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/task/twitter/UpdateStatusTask.kt @@ -745,17 +745,17 @@ class UpdateStatusTask( chucked: Boolean, callback: UploadCallback?): SharedMediaUploadResult { val deleteOnSuccess = ArrayList() val deleteAlways = ArrayList() - val mediaIds = media.mapIndexedToArray { index, media -> + val mediaIds = media.mapIndexedToArray { index, item -> val resp: Attachment //noinspection TryWithIdenticalCatches var body: MediaStreamBody? = null try { val sizeLimit = account.getMediaSizeLimit() - body = getBodyFromMedia(context, media, sizeLimit, chucked, + body = getBodyFromMedia(context, item, sizeLimit, chucked, ContentLengthInputStream.ReadListener { length, position -> callback?.onUploadingProgressChanged(index, position, length) }) - resp = mastodon.uploadMediaAttachment(body.body) + resp = mastodon.uploadMediaAttachment(body.body, item.alt_text) } catch (e: IOException) { throw UploadException(e).apply { this.deleteAlways = deleteAlways