Skip to content

Commit a6d3a4a

Browse files
author
Daniel Cohen
committed
updated documentation , fixed sample projects
1 parent 1c753ac commit a6d3a4a

8 files changed

Lines changed: 132 additions & 17 deletions

File tree

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ Cloudinary provides URL and HTTP based APIs that can be easily integrated with a
1313

1414
For Java, Cloudinary provides a library for simplifying the integration even further.
1515

16-
**Note:** This Java library is intended mainly for Web applications. For **Android** integration, there is a dedicated library with a similar interface: https://github.com/cloudinary/cloudinary_android
16+
**Note:** This readme intended mainly for Web applications. For **Android** specific instructions, see: https://github.com/cloudinary/cloudinary_java/cloudinary-android
1717

1818
## Getting started guide
1919
![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **Take a look at our [Getting started guide for Java](http://cloudinary.com/documentation/java_integration#getting_started_guide)**.
2020

2121
## Setup ######################################################################
2222

23-
The cloudinary_java library is available in [Maven Central](http://repo1.maven.org/maven/). To use it, add the following dependency to your pom.xml:
23+
The cloudinary_java library is available in [Maven Central](http://repo1.maven.org/maven/). To use it, add the following dependency to your pom.xml :
2424

2525
<dependency>
2626
<groupId>com.cloudinary</groupId>
27-
<artifactId>cloudinary</artifactId>
27+
<artifactId>cloudinary-http42</artifactId>
2828
<version>1.0.14</version>
2929
</dependency>
3030

31-
Alternatively, download cloudinary_java from [here](https://github.com/cloudinary/cloudinary_java/tarball/master)
32-
and see [pom.xml](https://github.com/cloudinary/cloudinary_java/blob/master/pom.xml) for library dependencies.
31+
Alternatively, download cloudinary_java from [here](https://github.com/cloudinary/cloudinary_java/cloudinary-http42/tarball/master)
32+
and see [pom.xml](https://github.com/cloudinary/cloudinary_java/cloudinary-http42/blob/master/pom.xml) for library dependencies.
3333

3434
## Try it right away
3535

@@ -156,8 +156,8 @@ Returns an html input field for direct image upload, to be used in conjunction w
156156

157157
Usage:
158158

159-
Map options = Cloudinary.asMap("resource_type", "auto");
160-
Map htmlOptions = Cloudinary.asMap("alt", "sample");
159+
Map options = ObjectUtils.asMap("resource_type", "auto");
160+
Map htmlOptions = ObjectUtils.asMap("alt", "sample");
161161
String html = cloudinary.uploader().imageUploadTag("image_id", options, htmlOptions);
162162

163163
![](http://res.cloudinary.com/cloudinary/image/upload/see_more_bullet.png) **See [our documentation](http://cloudinary.com/documentation/java_image_upload#direct_uploading_from_the_browser) for plenty more options of uploading directly from the browser**.
@@ -182,3 +182,4 @@ Or via Twitter: [@cloudinary](https://twitter.com/#!/cloudinary)
182182
## License #######################################################################
183183

184184
Released under the MIT license.
185+

cloudinary-android-test/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<plugin>
5252
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
5353
<artifactId>android-maven-plugin</artifactId>
54+
<version>4.0.0-rc.2</version>
5455
<configuration>
5556
<test>
5657
<createReport>true</createReport>

cloudinary-android-test/src/main/java/com/cloudinary/test/UploaderTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ public void testUnsignedUpload() throws Exception {
6666
to_sign.put("public_id", result.getString("public_id"));
6767
to_sign.put("version", ObjectUtils.asString(result.get("version")));
6868
Log.d("TestRunner",cloudinary.config.apiSecret);
69-
7069
String expected_signature = cloudinary.apiSignRequest(to_sign, cloudinary.config.apiSecret);
7170
assertEquals(result.get("signature"), expected_signature);
7271
}
@@ -295,10 +294,8 @@ public void testAutoTaggingRequest() {
295294
try {
296295
cloudinary.uploader().upload(getAssetStream("images/logo.png"), ObjectUtils.asMap("auto_tagging", 0.5f));
297296
} catch (Exception e) {
298-
Log.i("DANIEL",e.getMessage());
299297
for (int i = 0; i < e.getStackTrace().length; i++) {
300298
StackTraceElement x = e.getStackTrace()[i];
301-
Log.i("DANIEL",x.getClassName()+"."+x.getMethodName()+" "+x.getLineNumber());
302299
}
303300

304301

cloudinary-android/README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
Cloudinary
2+
==========
3+
4+
Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline.
5+
6+
Easily upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software.
7+
Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your website’s graphics requirements.
8+
Images are seamlessly delivered through a fast CDN, and much much more.
9+
10+
Cloudinary offers comprehensive APIs and administration capabilities and is easy to integrate with any web application, existing or new.
11+
12+
Cloudinary provides URL and HTTP based APIs that can be easily integrated with any Web development framework.
13+
14+
For Android, Cloudinary provides a library for simplifying the integration even further. The library requires Android 2.3 or higher.
15+
16+
## Manual Setup ######################################################################
17+
Download cloudinary-core-1.0.15.jar from [here](http://res.cloudinary.com/cloudinary/raw/upload/cloudinary-core-1.0.15.jar) and cloudinary-android-1.0.15.jar from [here](http://res.cloudinary.com/cloudinary/raw/upload/cloudinary-android-1.0.15.jar)
18+
and put them in your libs folder.
19+
20+
## Maven Integration ######################################################################
21+
The cloudinary_java library is available in [Maven Central](http://repo1.maven.org/maven/). To use it, add the following dependency to your pom.xml:
22+
23+
<dependency>
24+
<groupId>com.cloudinary</groupId>
25+
<artifactId>cloudinary-android</artifactId>
26+
<version>1.0.15</version>
27+
</dependency>
28+
29+
30+
## Try it right away
31+
32+
Sign up for a [free account](https://cloudinary.com/users/register/free) so you can try out image transformations and seamless image delivery through CDN.
33+
34+
*Note: Replace `demo` in all the following examples with your Cloudinary's `cloud name`.*
35+
36+
Accessing an uploaded image with the `sample` public ID through a CDN:
37+
38+
http://res.cloudinary.com/demo/image/upload/sample.jpg
39+
40+
![Sample](https://res.cloudinary.com/demo/image/upload/w_0.4/sample.jpg "Sample")
41+
42+
Generating a 150x100 version of the `sample` image and downloading it through a CDN:
43+
44+
http://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill/sample.jpg
45+
46+
![Sample 150x100](https://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill/sample.jpg "Sample 150x100")
47+
48+
Converting to a 150x100 PNG with rounded corners of 20 pixels:
49+
50+
http://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill,r_20/sample.png
51+
52+
![Sample 150x150 Rounded PNG](https://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill,r_20/sample.png "Sample 150x150 Rounded PNG")
53+
54+
For plenty more transformation options, see our [image transformations documentation](http://cloudinary.com/documentation/image_transformations).
55+
56+
Generating a 120x90 thumbnail based on automatic face detection of the Facebook profile picture of Bill Clinton:
57+
58+
http://res.cloudinary.com/demo/image/facebook/c_thumb,g_face,h_90,w_120/billclinton.jpg
59+
60+
![Facebook 90x120](https://res.cloudinary.com/demo/image/facebook/c_thumb,g_face,h_90,w_120/billclinton.jpg "Facebook 90x200")
61+
62+
For more details, see our documentation for embedding [Facebook](http://cloudinary.com/documentation/facebook_profile_pictures) and [Twitter](http://cloudinary.com/documentation/twitter_profile_pictures) profile pictures.
63+
64+
65+
## Usage
66+
67+
### Configuration
68+
69+
Each request for building a URL of a remote cloud resource must have the `cloud_name` parameter set.
70+
Each request to our secure APIs (e.g., image uploads, eager sprite generation) must have the `api_key` and `api_secret` parameters set.
71+
See [API, URLs and access identifiers](http://cloudinary.com/documentation/api_and_access_identifiers) for more details.
72+
73+
Setting the `cloud_name`, `api_key` and `api_secret` parameters can be done either directly in each call to a Cloudinary method,
74+
by when initializing the Cloudinary object, or by using the CLOUDINARY_URL meta-data property.
75+
76+
The entry point of the library is the Cloudinary object.
77+
78+
Here's an example of setting the configuration parameters programatically:
79+
80+
Map config = new HashMap();
81+
config.put("cloud_name", "n07t21i7");
82+
config.put("api_key", "123456789012345");
83+
config.put("api_secret", "abcdeghijklmnopqrstuvwxyz12");
84+
Cloudinary cloudinary = new Cloudinary(config);
85+
86+
Another example of setting the configuration parameters by providing the CLOUDINARY_URL value to the constructor:
87+
88+
Cloudinary cloudinary = new Cloudinary("cloudinary://123456789012345:abcdeghijklmnopqrstuvwxyz12@n07t21i7");
89+
90+
Giving the context will allow Cloudinary to configure from the application's meta-data.
91+
92+
Cloudinary cloudinary = new Cloudinary(Utils.cloudinaryUrlFromContext(getContext()));
93+
94+
Then add a meta-data property to your application section in the AndroidManifest.xml
95+
96+
<manifest>
97+
...
98+
<application>
99+
...
100+
<meta-data android:name="CLOUDINARY_URL" android:value="cloudinary://123456789012345:abcdeghijklmnopqrstuvwxyz12@n07t21i7"/>
101+
</application>
102+
<manifest>
103+
104+
### Embedding and transforming images
105+
106+
Any image uploaded to Cloudinary can be transformed and embedded using powerful view helper methods:
107+
108+
The following example generates the url for accessing an uploaded `sample` image while transforming it to fill a 100x150 rectangle:
109+
110+
cloudinary.url().transformation(new Transformation().width(100).height(150).crop("fill")).generate("sample.jpg")
111+
112+
...
113+

cloudinary-android/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<plugin>
4343
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
4444
<artifactId>android-maven-plugin</artifactId>
45-
<version>3.9.0-rc.1</version>
45+
<version>4.0.0-rc.2</version>
4646
<configuration>
4747
<sdk>
4848
<platform>19</platform>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<modules>
1717
<module>cloudinary-core</module>
1818
<module>cloudinary-android</module>
19-
<module>cloudinary-android-test</module>
2019
<module>cloudinary-taglib</module>
2120
<module>cloudinary-http42</module>
21+
<module>cloudinary-android-test</module>
2222
</modules>
2323

2424
<description>

samples/photo_album/src/main/java/cloudinary/controllers/PhotoController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import cloudinary.repositories.PhotoRepository;
77

88
import com.cloudinary.Cloudinary;
9+
import com.cloudinary.utils.ObjectUtils;
910
import com.cloudinary.Singleton;
1011

1112
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,7 +39,7 @@ public String uploadPhoto(@ModelAttribute PhotoUpload photoUpload, BindingResult
3839
Map uploadResult = null;
3940
if (photoUpload.getFile() != null && !photoUpload.getFile().isEmpty()) {
4041
uploadResult = Singleton.getCloudinary().uploader().upload(photoUpload.getFile().getBytes(),
41-
Cloudinary.asMap("resource_type", "auto"));
42+
ObjectUtils.asMap("resource_type", "auto"));
4243
photoUpload.setPublicId((String) uploadResult.get("public_id"));
4344
photoUpload.setVersion((Long) uploadResult.get("version"));
4445
photoUpload.setSignature((String) uploadResult.get("signature"));
@@ -79,15 +80,15 @@ public String directUnsignedUploadPhotoForm(ModelMap model) throws Exception {
7980
model.addAttribute("photoUpload", new PhotoUpload());
8081
model.addAttribute("unsigned", true);
8182
Cloudinary cld = Singleton.getCloudinary();
82-
String preset = "sample_" + cld.apiSignRequest(Cloudinary.asMap("api_key", cld.getStringConfig("api_key")), cld.getStringConfig("api_secret")).substring(0, 10);
83+
String preset = "sample_" + cld.apiSignRequest(ObjectUtils.asMap("api_key", cld.config.apiKey), cld.config.apiSecret).substring(0, 10);
8384
model.addAttribute("preset", preset);
8485
try {
85-
Singleton.getCloudinary().api().createUploadPreset(Cloudinary.asMap(
86+
Singleton.getCloudinary().api().createUploadPreset(ObjectUtils.asMap(
8687
"name", preset,
8788
"unsigned", true,
8889
"folder", "preset_folder"));
8990
} catch (Exception e) {
9091
}
9192
return "direct_upload_form";
9293
}
93-
}
94+
}

samples/photo_album_gae/src/main/java/cloudinary/controllers/PhotoController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import cloudinary.lib.PhotoUploadValidator;
44
import cloudinary.models.PhotoUpload;
55
import com.cloudinary.Cloudinary;
6+
import com.cloudinary.utils.ObjectUtils;
67
import com.cloudinary.Singleton;
78
import org.springframework.stereotype.Controller;
89
import org.springframework.ui.ModelMap;
@@ -27,6 +28,7 @@
2728
@Controller
2829
@RequestMapping("/")
2930
public class PhotoController {
31+
3032
private final static GAEConnectionManager connectionManager = new GAEConnectionManager();
3133
@RequestMapping(value = "/", method = RequestMethod.GET)
3234
public String listPhotos(ModelMap model) {
@@ -50,7 +52,7 @@ public String uploadPhoto(@ModelAttribute PhotoUpload photoUpload, BindingResult
5052
if (photoUpload.getFile() != null && !photoUpload.getFile().isEmpty()) {
5153
Singleton.getCloudinary().config.properties.put("connectionManager", connectionManager);
5254
uploadResult = Singleton.getCloudinary().uploader().upload(photoUpload.getFile().getBytes(),
53-
Cloudinary.asMap("resource_type", "auto"));
55+
ObjectUtils.asMap("resource_type", "auto"));
5456

5557
photoUpload.setPublicId((String) uploadResult.get("public_id"));
5658
photoUpload.setVersion((Long) uploadResult.get("version"));

0 commit comments

Comments
 (0)