Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multipage conversion #93

Merged
merged 2 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 multipage conversion.
rsedykh marked this conversation as resolved.
Show resolved Hide resolved
- 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)