Skip to content

Commit

Permalink
Merge pull request #93 from /issues/86-multipage-conversion
Browse files Browse the repository at this point in the history
Multipage conversion
  • Loading branch information
onthecrow authored Nov 8, 2023
2 parents b32902a + ac7026c commit d63a1d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
- 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:
- Migrated Gradle builds from Groovy to Kotlin.
- 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ abstract class Converter(private val client: UploadcareClient,
private val conversionJobs: List<ConversionJob>) {

private var store: String? = null
private var saveInGroup: String? = null

private var job: Job? = null

Expand Down Expand Up @@ -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<UploadcareFile> {
val results = ArrayList<UploadcareFile>()

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()
Expand Down Expand Up @@ -229,4 +241,4 @@ enum class VideoResizeMode constructor(val rawValue: String) {
CHANGE_RATIO("change_ratio"),
SCALE_CROP("scale_crop"),
LETTERBOX("add_padding")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.uploadcare.android.library.data

internal data class ConvertData(val paths: List<String>, val store: String? = null)
import com.squareup.moshi.Json

internal data class ConvertData(
val paths: List<String>,
val store: String? = null,
@Json(name = "save_in_group") val saveInGroup: String?
)

internal data class ConvertResultData(
val problems: Map<String, String>,
Expand All @@ -16,4 +22,4 @@ internal data class ConvertStatusData(
val result: ConvertStatusResultData,
val error: String? = null)

internal data class ConvertStatusResultData(val uuid: String)
internal data class ConvertStatusResultData(val uuid: String)

0 comments on commit d63a1d0

Please sign in to comment.