diff --git a/CHANGELOG.md b/CHANGELOG.md index 245b7cc0..aff154e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Added support for new event types of webhooks. - Removed sorting methods by file size, as the corresponding parameter has been removed from the API query parameters. + - Added support for converting multipage into a group of files. - Widget: - SocialApi doesn't use `GET /sources` method anymore. - Project: @@ -17,7 +18,6 @@ - Example: - Removed sorting options by file size from `UploadFragment`. - ## 3.3.0 - Library: - Added support for [signing your webhooks](https://uploadcare.com/docs/webhooks/#signed-webhooks) using the `signingSecret` parameter. diff --git a/library/src/main/java/com/uploadcare/android/library/conversion/Converter.kt b/library/src/main/java/com/uploadcare/android/library/conversion/Converter.kt index da99d10b..396db6b8 100644 --- a/library/src/main/java/com/uploadcare/android/library/conversion/Converter.kt +++ b/library/src/main/java/com/uploadcare/android/library/conversion/Converter.kt @@ -24,6 +24,7 @@ abstract class Converter(private val client: UploadcareClient, private val conversionJobs: List) { private var store: String? = null + private var saveInGroup: String? = null private var job: Job? = null @@ -76,12 +77,23 @@ abstract class Converter(private val client: UploadcareClient, return this } + /** + * Convert a multi-page document into a group of files. + * + * @param saveInGroup is set true - multi-page documents additionally will be saved as a file group. + * is set false - multi-page documents won't be saved as a file group. + */ + fun saveInGroup(saveInGroup: Boolean): Converter { + this.saveInGroup = if (saveInGroup) 1.toString() else 0.toString() + return this + } + @Throws(UploadcareApiException::class) fun convert(pollingInterval: Long): List { val results = ArrayList() - val convertData = ConvertData(getPaths(), store) + val convertData = ConvertData(getPaths(), store, saveInGroup) val requestBodyContent = client.objectMapper.toJson(convertData, ConvertData::class.java) val body = requestBodyContent.encodeUtf8().toRequestBody(RequestHelper.JSON) val url = getConversionUri() @@ -229,4 +241,4 @@ enum class VideoResizeMode constructor(val rawValue: String) { CHANGE_RATIO("change_ratio"), SCALE_CROP("scale_crop"), LETTERBOX("add_padding") -} \ No newline at end of file +} diff --git a/library/src/main/java/com/uploadcare/android/library/data/ConvertData.kt b/library/src/main/java/com/uploadcare/android/library/data/ConvertData.kt index 2008b0c0..3a83b6ba 100644 --- a/library/src/main/java/com/uploadcare/android/library/data/ConvertData.kt +++ b/library/src/main/java/com/uploadcare/android/library/data/ConvertData.kt @@ -1,6 +1,12 @@ package com.uploadcare.android.library.data -internal data class ConvertData(val paths: List, val store: String? = null) +import com.squareup.moshi.Json + +internal data class ConvertData( + val paths: List, + val store: String? = null, + @Json(name = "save_in_group") val saveInGroup: String? +) internal data class ConvertResultData( val problems: Map, @@ -16,4 +22,4 @@ internal data class ConvertStatusData( val result: ConvertStatusResultData, val error: String? = null) -internal data class ConvertStatusResultData(val uuid: String) \ No newline at end of file +internal data class ConvertStatusResultData(val uuid: String)