Java library for Uploadcare.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
src
.gitignore
.travis.yml Change JDK matrix Nov 2, 2018
AUTHORS.txt
HISTORY.md
LICENSE Update LICENSE Jun 28, 2016
README.md
pom.xml

README.md

uploadcare-java

Build Status Maven Central Javadocs Uploadcare stack on StackShare

This is a Java library for Uploadcare.

Supported features:

  • Complete file and project APIs v0.4
  • Paginated resources are fetched as List<T>
  • CDN path builder
  • File uploads from local storages, byte arrays or URLs

Maven

The latest stable version of the lib is available from Maven Central.

Including it in your build is done through adding the following to the <dependencies /> section of your project's pom.xml file.

<dependency>
    <groupId>com.uploadcare</groupId>
    <artifactId>uploadcare</artifactId>
    <version>3.2.0</version>
</dependency>

Examples

Don't forget to grab your API keys prior to trying out the examples.

Basic API Usage

Client client = new Client("publickey", "privatekey");
Project project = client.getProject();
Project.Collaborator owner = project.getOwner();

List<URI> published = new ArrayList<URI>();
Iterable<File> files = client.getFiles().asIterable();
for (File file : files) {
    if (file.isMadePublic()) {
        published.add(file.getOriginalFileUrl());
    }
}

Check out the docs for details:

Building CDN URLs

File file = client.getFile("85b5644f-e692-4855-9db0-8c5a83096e25");
CdnPathBuilder builder = file.cdnPath()
        .resizeWidth(200)
        .cropCenter(200, 200)
        .grayscale();
URI url = Urls.cdn(builder);

Check out the docs for details:

File uploads

Client client = Client.demoClient();
java.io.File file = new java.io.File("olympia.jpg");
Uploader uploader = new FileUploader(client, sourceFile);
try {
    File file = uploader.upload().save();
    System.out.println(file.getOriginalFileUrl());
} catch (UploadFailureException e) {
    System.out.println("Upload failed :(");
}

Check out the docs for details:

Contributors

See AUTHORS.txt and here.

Security issues

If you think you ran into something in Uploadcare libraries which might have security implications, please hit us up at bugbounty@uploadcare.com or Hackerone.

We'll contact you personally in a short time to fix an issue through co-op and prior to any public disclosure.