Skip to content

NewAmsterdamLabs/uploadcare-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.6.
  • Paginated resources are fetched as List<T>.
  • CDN path builder.
  • File uploading from a local storage, byte arrays, URLs, and signed uploads.

Maven

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.

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

Examples

Get your API keys to proceed with the examples below.

Read class documentation on javadoc.io.

Basic API Usage

Client client = new Client("publickey", "secretkey");
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());
    }
}

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);

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 :(");
}

Contributors

See AUTHORS.txt and our contributors.

Security issues

If you spotted or experienced any security implications while using Uploadcare libraries, hit us up at [email protected] or Hackerone. We'll contact you shortly to fix this security issue.

Packages

No packages published

Languages

  • Java 100.0%