@@ -109,4 +109,111 @@ The following example generates the url for accessing an uploaded `sample` image
109109
110110 cloudinary.url().transformation(new Transformation().width(100).height(150).crop("fill")).generate("sample.jpg")
111111
112- ...
112+ Another example, emedding a smaller version of an uploaded image while generating a 90x90 face detection based thumbnail:
113+
114+ cloudinary.url().transformation(new Transformation().width(90).height(90).crop("thumb").gravity("face")).generate("woman.jpg")
115+
116+ You can provide either a Facebook name or a numeric ID of a Facebook profile or a fan page.
117+
118+ Embedding a Facebook profile to match your graphic design is very simple:
119+
120+ cloudinary.url().type("facebook").transformation(new Transformation().width(130).height(130).crop("fill").gravity("north_west")).generate("billclinton.jpg")
121+
122+ Same goes for Twitter:
123+
124+ cloudinary.url().type("twitter_name").generate("billclinton.jpg")
125+
126+ ### Upload
127+
128+ Assuming you have your Cloudinary configuration parameters defined (` cloud_name ` , ` api_key ` , ` api_secret ` ), uploading to Cloudinary is very simple.
129+
130+ The following example uploads a local JPG available as an InputStream to the cloud:
131+
132+ cloudinary.uploader().upload(inputStream, Cloudinary.emptyMap())
133+
134+ The uploaded image is assigned a randomly generated public ID. The image is immediately available for download through a CDN:
135+
136+ cloudinary.url().generate("abcfrmo8zul1mafopawefg.jpg")
137+
138+ http://res.cloudinary.com/demo/image/upload/abcfrmo8zul1mafopawefg.jpg
139+
140+ You can also specify your own public ID:
141+
142+ cloudinary.uploader().upload("http://www.example.com/image.jpg ", Cloudinary.asMap("public_id", "sample_remote"))
143+
144+ cloudinary.url().generate("sample_remote.jpg")
145+
146+ http://res.cloudinary.com/demo/image/upload/sample_remote.jpg
147+
148+ ### Safe mobile uploading
149+
150+ Android applications might prefer to avoid keeping the sensitive ` api_secret ` on the mobile device. It is recommended to generate the upload authentication signature on the server side.
151+ This way the ` api_secret ` is stored only on the much safer server-side.
152+
153+ Cloudinary's Android SDK allows providing server-generated signature and any additional parameters that were generated on the server side (instead of signing using ` api_secret ` locally).
154+
155+ The following example intializes Cloudinary without any authentication parameters:
156+
157+ Map config = new HashMap();
158+ config.put("cloud_name", "n07t21i7");
159+ Cloudinary mobileCloudinary = new Cloudinary(config);
160+
161+ Alternatively replace your CLOUDINARY_URL meta-data property as follows:
162+
163+ <meta-data android:name="CLOUDINARY_URL" android:value="cloudinary://n07t21i7"/>
164+
165+ Your server can use any Cloudinary libraries (Ruby on Rails, PHP, Python & Django, Java, Perl, .Net, etc.) for generating the signature. The following JSON in an example of a response of an upload authorization request to your server:
166+
167+ {
168+ "signature": "sgjfdoigfjdgfdogidf9g87df98gfdb8f7d6gfdg7gfd8",
169+ "public_id": "abdbasdasda76asd7sa789",
170+ "timestamp": 1346925631,
171+ "api_key": "123456789012345"
172+ }
173+
174+ The following code uploads an image to Cloudinary with the parameters generated safely on the server side (e.g., from a JSON as in the example above):
175+
176+ cloudinary.uploader().upload(inputStream, Cloudinary.asMap("public_id", publicId, "signature", signature, "timestamp", timestamp, "api_key", api_key))
177+
178+ You might want to reference uploaded Cloudinary images and raw files using an identifier string of the following format:
179+
180+ resource_type:type:identifier.format
181+
182+ The following example generates a Cloudinary URL based on an idenfier of the format mentioned above:
183+
184+ String imageIdentifier = "image:upload:dfhjghjkdisudgfds7iyf.jpg";
185+ String[] components = imageIdentifier.split(":");
186+
187+ String url = cloudinary.url().resourceType(components[0]).type(components[1]).generate(components[2]);
188+
189+ // http://res.cloudinary.com/n07t21i7/image/upload/dfhjghjkdisudgfds7iyf.jpg
190+
191+ Same can work for raw file uploads:
192+
193+ String rawIdentifier = "raw:upload:cguysfdsfuydsfyuds31.doc";
194+ String[] components = rawIdentifier.split(":");
195+
196+ String url = cloudinary.url().resourceType(components[0]).type(components[1]).generate(components[2]);
197+
198+ // http://res.cloudinary.com/n07t21i7/raw/upload/cguysfdsfuydsfyuds31.doc
199+
200+ ## Additional resources ##########################################################
201+
202+ Additional resources are available at:
203+
204+ * [ Website] ( http://cloudinary.com )
205+ * [ Documentation] ( http://cloudinary.com/documentation )
206+ * [ Image transformations documentation] ( http://cloudinary.com/documentation/image_transformations )
207+ * [ Upload API documentation] ( http://cloudinary.com/documentation/upload_images )
208+
209+ ## Support
210+
211+ You can [ open an issue through GitHub] ( https://github.com/cloudinary/cloudinary_android/issues ) .
212+
213+ 214+
215+ Or via Twitter: [ @cloudinary ] ( https://twitter.com/#!/cloudinary )
216+
217+ ## License #######################################################################
218+
219+ Released under the MIT license.
0 commit comments