Skip to content

Commit

Permalink
Add check from URL status.
Browse files Browse the repository at this point in the history
Add check document and video conversion statuses.
  • Loading branch information
CheK539 committed Dec 7, 2023
1 parent 612aa9b commit 85b7254
Show file tree
Hide file tree
Showing 6 changed files with 364 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
**Library changes:**
- Added file metadata [features](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/File-metadata).
- Added delete group [method](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Group/operation/deleteGroup).
- Added check from URL status [method](https://uploadcare.com/api-refs/upload-api/#tag/Upload/operation/fromURLUploadStatus).
- Added check document conversion status [method](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion/operation/documentConvert).
- Added check video conversion status [method](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion/operation/videoConvertStatus).

## 4.0.0

Expand Down
156 changes: 156 additions & 0 deletions documentation/LIBRARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
* [Copy file to remote storage](#copy-file-to-remote-storage-api-reference)
* [List of groups](#list-of-groups-api-reference)
* [Group info](#group-info-api-reference)
* [Delete group](#delete-group-api-reference)
* [Store group](#store-group-api-reference)
* [Project info](#project-info-api-reference)
* [List of webhooks](#list-of-webhooks-api-reference)
* [Create webhook](#create-webhook-api-reference)
* [Update webhook](#update-webhook-api-reference)
* [Delete webhook](#delete-webhook-api-reference)
* [Convert documents](#convert-documents-api-reference)
* [Check document conversion status](#check-document-conversion-status-api-reference)
* [Convert videos](#convert-videos-api-reference)
* [Check video conversion status](#check-video-conversion-status-api-reference)
* [Content delivery](#content-delivery-reference)
* [Secure Content delivery](#secure-content-delivery-reference)
* [Execute AWS Rekognition](#execute-aws-rekognition-api-reference)
Expand All @@ -35,6 +38,7 @@
* [Initialization Upload](#initialization-upload)
* [Upload File](#upload-file-api-reference)
* [Upload File from URL](#upload-file-url-api-reference)
* [Check upload File from URL Status](#check-upload-file-from-url-status-api-reference)
* [Create file group](#create-files-group-api-reference)

## Initialization
Expand Down Expand Up @@ -866,6 +870,57 @@ DocumentConverter converter = new DocumentConverter(uploadcare, conversionJobs);
List<UploadcareFile> result = converter.convert();
```

## Check document conversion status ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion/operation/documentConvertStatus)) ##

##### Asynchronous check document conversion status.

Kotlin
```kotlin
uploadcare.getDocumentConversionStatusAsync(
context = context,
token = 12345678,
callback = object : ConversionStatusCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: ConvertStatusData) {
// Successfully fetched status.
}
}
)
```

Java
```java
uploadcare.getDocumentConversionStatusAsync(
context,
12345678,
new ConversionStatusCallback() {
@Override
public void onFailure(@NonNull UploadcareApiException e) {
// Handle errors.
}

@Override
public void onSuccess(@NonNull ConvertStatusData result) {
// Successfully fetched status.
}
});
```

##### Synchronous check document conversion status.

Kotlin
```kotlin
val status = client.getDocumentConversionStatus(12345678)
```

Java
```java
ConvertStatusData status = uploadcare.getDocumentConversionStatus(12345678);
```

## Convert videos ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/videoConvert)) ##

##### Asynchronous videos convert.
Expand Down Expand Up @@ -959,6 +1014,57 @@ VideoConverter converter = new VideoConverter(uploadcare, conversionJobs);
List<UploadcareFile> result = converter.convert();
```

## Check video conversion status ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion/operation/videoConvertStatus)) ##

##### Asynchronous check video conversion status.

Kotlin
```kotlin
uploadcare.getVideoConversionStatusAsync(
context = context,
token = 12345678,
callback = object : ConversionStatusCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: ConvertStatusData) {
// Successfully fetched status.
}
}
)
```

Java
```java
uploadcare.getVideoConversionStatusAsync(
context,
12345678,
new ConversionStatusCallback() {
@Override
public void onFailure(@NonNull UploadcareApiException e) {
// Handle errors.
}

@Override
public void onSuccess(@NonNull ConvertStatusData result) {
// Successfully fetched status.
}
});
```

##### Synchronous check video conversion status.

Kotlin
```kotlin
val status = client.getVideoConversionStatus(12345678)
```

Java
```java
ConvertStatusData status = uploadcare.getVideoConversionStatus(12345678);
```

## Content delivery ([Reference](https://uploadcare.com/docs/delivery/cdn/)) ##

##### CDN URLs build.
Expand Down Expand Up @@ -1746,6 +1852,56 @@ try {
}
```

## Check upload File from URL Status ([API Reference](https://uploadcare.com/api-refs/upload-api/#tag/Upload/operation/fromURLUploadStatus)) ##

##### Asynchronous check upload file from URL status.

Kotlin
```kotlin
uploadcare.getFromUrlStatusAsync(
context = context,
token = "YOUR_TOKEN",
callback = object : UploadFromUrlStatusCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: UploadFromUrlStatusData) {
// Successfully fetched status.
}
})
```

Java
```java
uploadcare.getFromUrlStatusAsync(
context,
"YOUR_TOKEN",
new UploadFromUrlStatusCallback() {
@Override
public void onFailure(@NonNull UploadcareApiException e) {
// Handle errors.
}

@Override
public void onSuccess(@NonNull UploadFromUrlStatusData result) {
// Successfully fetched status.
}
});
```

##### Synchronous check upload file from URL status.

Kotlin
```kotlin
val fromUrlStatus = client.getFromUrlStatus(urlToken)
```

Java
```java
UploadFromUrlStatusData urlStatus = uploadcare.getFromUrlStatus("YOUR_TOKEN");
```

## Create file group ([API Reference](https://uploadcare.com/api-refs/upload-api/#operation/createFilesGroup)) ##

##### Asynchronous file group create.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,35 @@ package com.uploadcare.android.example.viewmodels
import android.app.Application
import android.content.Context
import android.net.Uri
import android.util.Log
import android.view.View
import android.view.inputmethod.InputMethodManager
import androidx.activity.result.ActivityResultLauncher
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.switchMap
import androidx.lifecycle.viewModelScope
import com.google.android.material.textfield.TextInputEditText
import com.uploadcare.android.example.R
import com.uploadcare.android.library.api.UploadcareClient
import com.uploadcare.android.library.api.UploadcareFile
import com.uploadcare.android.library.callbacks.ConversionStatusCallback
import com.uploadcare.android.library.callbacks.UploadFileCallback
import com.uploadcare.android.library.callbacks.UploadFilesCallback
import com.uploadcare.android.library.callbacks.UploadFromUrlStatusCallback
import com.uploadcare.android.library.data.ConvertStatusData
import com.uploadcare.android.library.data.UploadFromUrlStatusData
import com.uploadcare.android.library.exceptions.UploadcareApiException
import com.uploadcare.android.library.upload.*
import com.uploadcare.android.widget.controller.SocialNetwork
import com.uploadcare.android.widget.controller.UploadcareWidget
import com.uploadcare.android.widget.controller.UploadcareWidgetResult
import com.uploadcare.android.widget.utils.SingleLiveEvent
import com.uploadcare.android.widget.controller.UploadcareWidgetParams
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.*
import kotlin.math.roundToInt

Expand Down Expand Up @@ -61,6 +70,69 @@ class UploadViewModel(application: Application) : AndroidViewModel(application)
*/
private val client = UploadcareWidget.getInstance().uploadcareClient

init {
viewModelScope.launch(Dispatchers.IO) {
val urlToken = "14ff1e69-e30f-495c-8230-e5963d913388"
val documentToken = 40213938
val videoToken = 1317628550

val fromUrlStatus = client.getFromUrlStatus(urlToken)
val documentStatus = client.getDocumentConversionStatus(documentToken)
val videoStatus = client.getVideoConversionStatus(videoToken)

client.getFromUrlStatusAsync(
context = application,
token = urlToken,
callback = object : UploadFromUrlStatusCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: UploadFromUrlStatusData) {
// Successfully fetched status.
Log.d("TAG", "Async $result")
}
}
)

client.getDocumentConversionStatusAsync(
context = application,
token = documentToken,
callback = object : ConversionStatusCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: ConvertStatusData) {
// Successfully fetched status.
Log.d("TAG", "Async $result")
}
}
)

client.getVideoConversionStatusAsync(
context = application,
token = videoToken,
callback = object : ConversionStatusCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: ConvertStatusData) {
// Successfully fetched status.
Log.d("TAG", "Async $result")
}
}
)

withContext(Dispatchers.Main) {
Log.d("TAG", "Sync $fromUrlStatus")
Log.d("TAG", "Sync $documentStatus")
Log.d("TAG", "Sync $videoStatus")
}
}
}

fun launchGetFiles() {
launchGetFilesCommand.call()
}
Expand Down
Loading

0 comments on commit 85b7254

Please sign in to comment.