The Cloudinary Java SDK allows you to quickly and easily integrate your application with Cloudinary. Effortlessly optimize and transform your cloud's assets.
This Readme provides basic installation and usage information. For the complete documentation, see the Java SDK Guide.
Table of Contents
- Transform and optimize assets (links to docs).
- Upload assets to cloud
|SDK Version||Java 6+|
|1.1.0 - 1.33.0||V|
The cloudinary_java library is available in Maven Central. To use it, add the following dependency to your pom.xml :
<dependency> <groupId>com.cloudinary</groupId> <artifactId>cloudinary-http44</artifactId> <version>1.33.0</version> </dependency>
Alternatively, download cloudinary_java from here and here and see build.gradle for library dependencies.
Each request for building a URL of a remote cloud resource must have the
cloud_name parameter set.
Each request to our secure APIs (e.g., image uploads, eager sprite generation) must have the
api_secret parameters set.
See API, URLs and access identifiers for more details.
api_secret parameters can be done either directly in each call to a Cloudinary method,
by when initializing the Cloudinary object, or by using the CLOUDINARY_URL environment variable / system property.
The entry point of the library is the Cloudinary object.
Cloudinary cloudinary = new Cloudinary();
Here's an example of setting the configuration parameters programatically:
Map config = new HashMap(); config.put("cloud_name", "n07t21i7"); config.put("api_key", "123456789012345"); config.put("api_secret", "abcdeghijklmnopqrstuvwxyz12"); Cloudinary cloudinary = new Cloudinary(config);
Another example of setting the configuration parameters by providing the CLOUDINARY_URL value to the constructor:
Cloudinary cloudinary = new Cloudinary("cloudinary://123456789012345:abcdeghijklmnopqrstuvwxyz12@n07t21i7");
Transform and Optimize Assets
- See full documentation Any image uploaded to Cloudinary can be transformed and embedded using powerful view helper methods:
The following example generates the url for accessing an uploaded
sample image while transforming it to fill a 100x150 rectangle:
Another example, emedding a smaller version of an uploaded image while generating a 90x90 face detection based thumbnail:
You can provide either a Facebook name or a numeric ID of a Facebook profile or a fan page.
Embedding a Facebook profile to match your graphic design is very simple:
Assuming you have your Cloudinary configuration parameters defined (
api_secret), uploading to Cloudinary is very simple.
The following example uploads a local JPG to the cloud:
The uploaded image is assigned a randomly generated public ID. The image is immediately available for download through a CDN:
cloudinary.url().generate("abcfrmo8zul1mafopawefg.jpg"); # http://res.cloudinary.com/demo/image/upload/abcfrmo8zul1mafopawefg.jpg
You can also specify your own public ID:
cloudinary.uploader().upload("http://www.example.com/image.jpg", ObjectUtils.asMap("public_id", "sample_remote")); cloudinary.url().generate("sample_remote.jpg"); # http://res.cloudinary.com/demo/image/upload/sample_remote.jpg
- Open a Github issue (for issues related to the SDK)
- Open a support ticket (for issues related to your account)
Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive and personalized visual-media experiences—irrespective of the viewing device.
- Cloudinary Transformation and REST API References: Comprehensive references, including syntax and examples for all SDKs.
- MediaJams.dev: Bite-size use-case tutorials written by and for Cloudinary Developers
- DevJams: Cloudinary developer podcasts on YouTube.
- Cloudinary Academy: Free self-paced courses, instructor-led virtual courses, and on-site courses.
- Code Explorers and Feature Demos: A one-stop shop for all code explorers, Postman collections, and feature demos found in the docs.
- Cloudinary Roadmap: Your chance to follow, vote, or suggest what Cloudinary should develop next.
- Cloudinary Facebook Community: Learn from and offer help to other Cloudinary developers.
- Cloudinary Account Registration: Free Cloudinary account registration.
- Cloudinary Website
Released under the MIT license.