Java integration handles uploads and file operations by wrapping Uploadcare Upload API and REST API. This comprehensive API client lets you use most of the Uploadcare features from within your Java app.
Uploading (Upload API):
File management (REST API):
List<T>Image processing (URL API):
Security features:
Go to your Uploadcare Dashboard and create a new project for your Java app. It’ll have API keys to complete Java API client integration.
The latest stable library version is available at Maven Central.
Include the following code into your build by adding the following dependencies
into pom.xml for your project.
To build with Gradle add to Gradle build file:
Client and basic API usageUse your Public and Secret API Keys from the Java project’s dashboard.
Create a new API Client:
Uploadcare CDN can process images by adding directives like this:
Here’s a Java example to automate CDN URL creation:
FileUploader and UrlUploaderCheck out two options to upload files with the Java Uploadcare library
Uploader interface.
Upload with UrlUploader:
Upload with FileUploader by providing java.io.File:
Note: the com.uploadcare.api.File#getOriginalFileUrl method returns a
combination of UUID and an original file name without whitespaces.
With Client, you get a few utility methods to retrieve and handle the
project-specific data, like fetching a file by a file id or listing all uploaded
files for the project. Note, ids are Uploadcare UUIDs
associated with files whenever they get uploaded.
Here’s a short example of navigating your files and retrieving 10 file names uploaded to your project after today’s midnight and matching some arbitrary pattern:
When Automatic File Storing in storage settings is on (default), all newly uploaded files will be stored permanently. If it’s switched off, all incoming files will be deleted in 24 hours to prevent your storage cluttering.
With Automatic File Storing. turned off, you can still store files
selectively via API. In Java, these per-file controls are provided by both
com.uploadcare.api.Client#saveFile taking a UUID as a parameter and
com.uploadcare.api.File#save.
You can connect an Amazon S3 Bucket to your Uploadcare account as custom storage for specific cases. See S3 storage docs on how to configure it.
With the Java library, you can move files to S3 storage with the
com.uploadcare.api.Client#copyFile java method. You can do
the same via remote_copy REST API.
Refer the GitHub and check out more java examples.
Read the full documentation on GitHub.