Skip to content

Commit

Permalink
Merge pull request #97 from /issues/87-latest-add-ons
Browse files Browse the repository at this point in the history
Add latest add-ons
  • Loading branch information
onthecrow authored Nov 13, 2023
2 parents c6623a7 + ab5a9ad commit 218648a
Show file tree
Hide file tree
Showing 18 changed files with 727 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
- Added support for converting multipage into a group of files.
- Added `default_effects` field in `UploadcareFile`.
- Added react to request throttling (429 code response).
- Added support for [object recognition](https://uploadcare.com/docs/intelligence/object-recognition/),
[unsafe content detection](https://uploadcare.com/docs/unsafe-content/),
[malware protection](https://uploadcare.com/docs/security/malware-protection/),
and [background removal](https://uploadcare.com/docs/remove-bg/).
- Fixed authorization signature for requests with url parameters.
- Widget:
- SocialApi doesn't use `GET /sources` method anymore.
- Project:
Expand Down
325 changes: 325 additions & 0 deletions documentation/LIBRARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -1251,3 +1251,328 @@ List<String> fileIds = ... // list of file UUID's

UploadcareGroup uploadcareGroup = uploadcare.createGroup(fileIds, null);
```

## Execute AWS Rekognition ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/awsRekognitionExecute)) ##

##### Asynchronous AWS Rekognition execute.

Kotlin
```kotlin
// Create AWS Rekognition Add-On
val addOn = AWSRekognitionAddOn(uploadcare)

// Execute
addOn.executeAsync("YOUR_FILE_UUID", object : UploadcareFileCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: UploadcareFile) {
// Successfully execute Add-On.
}
})
```

Java
```java
// Create AWS Rekognition Add-On
AWSRekognitionAddOn addOn = new AWSRekognitionAddOn(uploadcare);

// Execute
addOn.executeAsync(
"YOUR_FILE_UUID",
new UploadcareFileCallback() {
@Override
public void onFailure(@NotNull UploadcareApiException e) {
// Handle errors.
}

@Override
public void onSuccess(@NonNull UploadcareFile result) {
// Successfully execute Add-On.
}
});
```

##### Synchronous AWS Rekognition execute.

Kotlin
```kotlin
// Create AWS Rekognition Add-On
val addOn = AWSRekognitionAddOn(uploadcare)

// Execute
val executeResult = addOn.execute("YOUR_FILE_UUID")

// Check status
val statusResult = addOn.check(executeResult.requestId)

if (statusResult.status == AddOnStatus.DONE) {
// Get file with appdata field
uploadcare.getFileWithAppData("YOUR_FILE_UUID")
} else {
// Handle other statuses
}
```

Java
```java
// Create AWS Rekognition Add-On
AWSRekognitionAddOn addOn = new AWSRekognitionAddOn(uploadcare);

// Execute
AddOnExecuteResult executeResult = addOn.execute("YOUR_FILE_UUID");

// Check status
AddOnStatusResult statusResult = addOn.check(executeResult.getRequestId());

if (statusResult.getStatus() == AddOnStatus.DONE) {
// Get file with appdata field
uploadcare.getFileWithAppData("YOUR_FILE_UUID");
} else {
// Handle other statuses
}
```

## Execute AWS Rekognition Moderation ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/awsRekognitionDetectModerationLabelsExecute)) ##

##### Asynchronous AWS Rekognition Moderation execute.

Kotlin
```kotlin
// Create AWS Rekognition Add-On
val addOn = AWSRekognitionModerationAddOn(uploadcare)

// Execute
addOn.executeAsync(object : UploadcareFileCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: UploadcareFile) {
// Successfully execute Add-On.
}
})
```

Java
```java
// Create AWS Rekognition Add-On
AWSRekognitionModerationAddOn addOn = new AWSRekognitionModerationAddOn(uploadcare);

// Execute
addOn.executeAsync(
new UploadcareFileCallback() {
@Override
public void onFailure(@NotNull UploadcareApiException e) {
// Handle errors.
}

@Override
public void onSuccess(@NonNull UploadcareFile result) {
// Successfully execute Add-On.
}
});
```

##### Synchronous AWS Rekognition Moderation execute.

Kotlin
```kotlin
// Create AWS Rekognition Moderation Add-On
val addOn = AWSRekognitionModerationAddOn(uploadcare)

// Execute
val executeResult = addOn.execute("YOUR_FILE_UUID")

// Check status
val statusResult = addOn.check(executeResult.requestId)

if (statusResult.status == AddOnStatus.DONE) {
// Get file with appdata field
uploadcare.getFileWithAppData("YOUR_FILE_UUID")
} else {
// Handle other statuses
}
```

Java
```java
// Create AWS Rekognition Moderation Add-On
AWSRekognitionModerationAddOn addOn = new AWSRekognitionModerationAddOn(uploadcare);

// Execute
AddOnExecuteResult executeResult = addOn.execute("YOUR_FILE_UUID");

// Check status
AddOnStatusResult statusResult = addOn.check(executeResult.getRequestId());

if (statusResult.getStatus() == AddOnStatus.DONE) {
// Get file with appdata field
uploadcare.getFileWithAppData("YOUR_FILE_UUID");
} else {
// Handle other statuses
}
```

## Execute ClamAV ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/ucClamavVirusScanExecute)) ##

##### Asynchronous ClamAV execute.

Kotlin
```kotlin
// Create ClamAV Add-On
val addOn = ClamAVAddOn(uploadcare)

// Execute
addOn.executeAsync(object : UploadcareFileCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: UploadcareFile) {
// Successfully execute Add-On.
}
})
```

Java
```java
// Create ClamAV Add-On
ClamAVAddOn addOn = new ClamAVAddOn(uploadcare);

// Execute
addOn.executeAsync(
new UploadcareFileCallback() {
@Override
public void onFailure(@NotNull UploadcareApiException e) {
// Handle errors.
}

@Override
public void onSuccess(@NonNull UploadcareFile result) {
// Successfully execute Add-On.
}
});
```

##### Synchronous ClamAV execute.

Kotlin
```kotlin
// Create ClamAV Add-On
val addOn = ClamAVAddOn(uploadcare)

// Execute
val executeResult = addOn.execute("YOUR_FILE_UUID")

// Check status
val statusResult = addOn.check(executeResult.requestId)

if (statusResult.status == AddOnStatus.DONE) {
// Get file with appdata field
uploadcare.getFileWithAppData("YOUR_FILE_UUID")
} else {
// Handle other statuses
}
```

Java
```java
// Create ClamAV Add-On
ClamAVAddOn addOn = new ClamAVAddOn(uploadcare);

// Execute
AddOnExecuteResult executeResult = addOn.execute("YOUR_FILE_UUID");

// Check status
AddOnStatusResult statusResult = addOn.check(executeResult.getRequestId());

if (statusResult.getStatus() == AddOnStatus.DONE) {
// Get file with appdata field
uploadcare.getFileWithAppData("YOUR_FILE_UUID")
} else {
// Handle other statuses
}
```

## Execute Remove.bg ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Add-Ons/operation/removeBgExecute)) ##

##### Asynchronous Remove.bg execute.

Kotlin
```kotlin
// Create Remove.bg Add-On
val addOn = RemoveBgAddOn(uploadcare)

// Execute
addOn.executeAsync(object : UploadcareFileCallback {
override fun onFailure(e: UploadcareApiException) {
// Handle errors.
}

override fun onSuccess(result: UploadcareFile) {
// Successfully execute Add-On.
}
})
```

Java
```java
// Create Remove.bg Add-On
RemoveBgAddOn addOn = new RemoveBgAddOn(uploadcare);

// Execute
addOn.executeAsync(
new UploadcareFileCallback() {
@Override
public void onFailure(@NotNull UploadcareApiException e) {
// Handle errors.
}

@Override
public void onSuccess(@NonNull UploadcareFile result) {
// Successfully execute Add-On.
}
});
```

##### Synchronous Remove.bg execute.

Kotlin
```kotlin
// Create Remove.bg Add-On
val addOn = RemoveBgAddOn(uploadcare)

// Execute
val executeResult = addOn.execute("YOUR_FILE_UUID")

// Check status
val statusResult = addOn.check(executeResult.requestId)

if (statusResult.status == AddOnStatus.DONE) {
// Get file with appdata field
statusResult.result?.let { uploadcare.getFile(it.fileId) }
} else {
// Handle other statuses
}
```

Java
```java
// Create Remove.bg Add-On
RemoveBgAddOn addOn = new RemoveBgAddOn(uploadcare);

// Execute
AddOnExecuteResult executeResult = addOn.execute("YOUR_FILE_UUID");

// Check status
AddOnStatusResult statusResult = addOn.check(executeResult.getRequestId());

if (statusResult.getStatus() == AddOnStatus.DONE && statusResult.getResult() != null) {
// Get file with appdata field
uploadcare.getFile(statusResult.getResult().getFileId());
} else {
// Handle other statuses
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ class CdnFragment : Fragment(), MenuProvider {
viewModel.convertVideo()
true
}
R.id.action_execute_aws_rekognition -> {
viewModel.executeAWSRekognitionAddOn()
true
}
R.id.action_execute_aws_rekognition_moderation -> {
viewModel.executeAWSRekognitionModerationAddOn()
true
}
R.id.action_execute_clam_av -> {
viewModel.executeClamAVAddOn()
true
}
R.id.action_execute_remove_bg -> {
viewModel.executeRemoveBgAddOn()
true
}
else -> false
}

Expand Down
Loading

0 comments on commit 218648a

Please sign in to comment.