Giter Site home page Giter Site logo

cloudinary / cloudinary_java Goto Github PK

View Code? Open in Web Editor NEW
159.0 32.0 108.0 2.05 MB

Cloudinary Java Client Library

License: MIT License

Java 99.92% Shell 0.08%
java cloudinary-java-library sdk-java cloudinary cloudinary-sdk cloudinary-java-sdk cloudinary-api image-manipulation video-manipulation

cloudinary_java's Introduction

Build Status

Cloudinary

About

The Cloudinary Java SDK allows you to quickly and easily integrate your application with Cloudinary. Effortlessly optimize and transform your cloud's assets.

Additional documentation

This Readme provides basic installation and usage information. For the complete documentation, see the Java SDK Guide.

Table of Contents

Key Features

Version Support

SDK Version Java 6+
1.1.0 - 1.39.0 V

Installation

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-http45</artifactId>
    <version>1.39.0</version>
</dependency>

Alternatively, download cloudinary_java from here and here and see build.gradle for library dependencies.

Usage

Setup

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_key and api_secret parameters set. See API, URLs and access identifiers for more details.

Setting the cloud_name, api_key and 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:

cloudinary.url().transformation(new Transformation().width(100).height(150).crop("fill")).generate("sample.jpg");

Another example, emedding a smaller version of an uploaded image while generating a 90x90 face detection based thumbnail:

cloudinary.url().transformation(new Transformation().width(90).height(90).crop("thumb").gravity("face")).generate("woman.jpg");

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:

cloudinary.url().type("facebook").transformation(new Transformation().width(130).height(130).crop("fill").gravity("north_west")).generate("billclinton.jpg");

File upload

Assuming you have your Cloudinary configuration parameters defined (cloud_name, api_key, api_secret), uploading to Cloudinary is very simple.

The following example uploads a local JPG to the cloud:

cloudinary.uploader().upload("my_picture.jpg", ObjectUtils.emptyMap());

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

Contributions

See contributing guidelines.

Get Help

About Cloudinary

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.

Additional Resources

Licence

Released under the MIT license.

cloudinary_java's People

Contributors

adimiz1 avatar aditimadan-cloudinary avatar andershedstrom avatar asisayag2 avatar d-mendoza avatar daplf avatar dmarcosl avatar elevenfive avatar francistagbo avatar itaibenari avatar jbcpollak avatar michalkcloudinay avatar mustafa01ali avatar nadavofi avatar nadavs avatar nitzanj avatar patrick-tolosa avatar richgieg avatar shakiba avatar tallevami avatar taragano avatar theel0ja avatar tocker avatar wagaun avatar yakirp avatar yomesinc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudinary_java's Issues

Test on Android

Has this library been tested and confirmed to work on android, seen as the only reason anyone would write a java lib would be to use it on Android surely?
(no one writes java apps anymore right?)

EntityManager named defaultPersistenceUnit : Error

I am doing a POC for my project using cloudinary. We would be using cloudinary in our production environment in future after this POC.

I have converted the Maven Project to Dynamic web application. Following is the structure of the project.

http://res.cloudinary.com/public/image/upload/v1417059122/cloudinary_lz6imw.png

Following is the Error I am getting.

http://res.cloudinary.com/public/image/upload/v1417059129/Error_fhzlye.png

I have debugged and made sure that persistence.xml is inside the META-INF folder. But still spring is not able to find the 'defaultPersistenceUnit '.

Can you please help me out to fix it?

Not Working

Hi,
We downloaded the files and try to use as per instruction.
There is compilation error .Below code is mentioned in this page.

http://cloudinary.com/documentation/java_integration

There is compilation error in it.

import java.io.File;

import java.util.Map;

...

File toUpload = new File("daisy.png");

Map uploadResult = cloudinary.uploader().upload(toUpload);

We corrected the compilation error by using this code.

But it is still not working.

Map config = ObjectUtils.asMap(
"cloud_name", "my_cloud_name",
"api_key", "my_api_key",
"api_secret", "my_api_secret");
Cloudinary cloudinary = new Cloudinary(config);
Map result = cloudinary.api().resource("sample", ObjectUtils.emptyMap());

Combine multiple Effects

I'm trying to upload an image with 2 effects. I've tried multiple approaches but cannot get it work.

new Transformation().effect("blur:500").crop("scale").width(100).height(40).effect("blue:50")

How can I combine these 2 effects, or how can i add multiple Transformations into the upload of 1 picture.

What am I missing here?
Thank you for help!

Not uploading from local directory

I am using cloudinary-taglib-1.2.1,cloudinary-core-1.2.1,cloudinary-http44-1.2.1,

Its working perfectly fine with http url but not with local directory path.

uploadResult=cloudinary.uploader().upload(/home/***/im.jpg,options);----{Runtime Exception}

Exception in thread "main" java.lang.RuntimeException: Invalid URL for upload
at com.cloudinary.http44.UploaderStrategy.callApi(UploaderStrategy.java:140)
at com.cloudinary.Uploader.callApi(Uploader.java:22)
at com.cloudinary.Uploader.upload(Uploader.java:55)
at com.snapdeal.reviews.client.api.impl.ImageClientServiceImpl.uploadImage(ImageClientServiceImpl.java:73)
at com.snapdeal.reviews.client.api.impl.ImageClientServiceImpl.main(ImageClientServiceImpl.java:102)

Large image upload

Hey, Is there any image compression functionality provided to compress large camera images locally before uploading them ?

Runs upload on main thread?

I'm having trouble using version 1.2.2 (the latest version shown on your README) when I try to upload an image, it throws a android.os.NetworkOnMainThreadException.

I wrote a simple example that throws this exception, which I tested on an LG V20 running Android 7.0 on the December security update.

Support for non blocking and/or stream based image transfer

Hi,

As I read the code of the http44 connector I see that all methods of tranfer require for the file to be entirely on my server (being in memory or on the hard drive) before it can be sent to the cloudinary server. This is really a pitty because my server is only an intermediary, a gatekeeper. No need for it to ever store/have/hold then entire file in memory or HD.
Also non blocking support would allow for better handling of load. Now each file upload requires a thread which (given the size of the files) could be monopolized for a long time.

Could there not be a non-blocking and/or stream based implementation for cloudinary java API?

Plans for a JSF taglib?

We are using the JSP successor JSF. Do you have a taglib for JSF?

JSF is the new industry standard in Java EE framework and out since 2004, so maybe you should also support it, which is good sales argument.

Porting your JSP tags to JSF should not be that complex.

Cloudinary.asMap("object1", "object2") shows DEPRECATED !!

Hi @cloudinary team..

I have been exploring Cloudinary Android SDK since 2 days now..

But I found that Cloudinary.asMap("object1", "object2") method is DEPRECATED which is necessary to be used inside:

cloudinary.uploader().upload("http://imagesource.com/xyz.png", Cloudinary.asMap("object1", "object2"));

After some SDK source code digging, i found that it works if we use:

.. ObjectUtils.asMap("object1", "object2"));

Please update the README accordingly :)

Thank you.

How to use Upload functionality in Java in Playfarmework ?

As per the Java Image upload doc. This should work for uploading images:-
import com.cloudinary.Cloudinary;
Cloudinary cloudinary = new Cloudinary();
cloudinary.upload(fileRef, ObjectUtils.emptyMap());

However I am not able to find any ObjectUtils class in com.cloudinary.* packages.

I am using following sbt dependnecy
"com.cloudinary" % "cloudinary" % "1.0.14"

Can someone please let me know, how I can fix it ?

Thanks,
Ankit

Must supply API KEY when doing unsigned upload

The UploaderStrategy is requiring for an api key even though I'm doing unsigned upload:
String apiKey = ObjectUtils.asString(options.get("api_key"), this.cloudinary().config.apiKey);
if (apiKey == null)
throw new IllegalArgumentException("Must supply api_key");

maven central

Can you submit cloudinary java to maven central? Looks like you already have a pom file.

Cloudinary uploading pictures / Missing required parameter - file

I am trying to use Cloudinary in Android Studio, uploading pictures, and videos but getting an error as it shows in the stack trace :
Caused by: java.lang.RuntimeException: Missing required parameter - file
as soon i chose a picture from the intent gallery and the progress dialog box pop up, it frees then the app shutdown, will it just prompt that it will but it goes back to the upload activity window.

I've tried to apply the same code for Video, but i got the same issue, which i am still trying to find out and understand how the right syntax works.

My code is :
`import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.StrictMode;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.cloudinary.Cloudinary;
import com.cloudinary.utils.ObjectUtils;

import java.io.IOException;

public class Upload extends AppCompatActivity implements View.OnClickListener {

public static final int RESULT_LOAD_IMAGE = 1;
ImageView imgToUpload;
Button buttonUploadSubmit;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.upload);
    if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }

    imgToUpload = (ImageView) findViewById(R.id.imgToUpload);
    buttonUploadSubmit = (Button) findViewById(R.id.ButtonUploadSubmit);

    imgToUpload.setOnClickListener(this);
    buttonUploadSubmit.setOnClickListener(this);

}

@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.imgToUpload:
            Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);

            break;
        case R.id.ButtonUploadSubmit:
            UploadTask uploadTask = new UploadTask();
            uploadTask.execute(String.valueOf(imgToUpload));

            break;
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Uri selectedImage = data.getData();
    imgToUpload.setImageURI(selectedImage);
}


class UploadTask extends AsyncTask<String, Void, Void>{

    ProgressDialog progressDialog;

   @Override
   protected void onPreExecute(){
        progressDialog = new ProgressDialog(Upload.this);
       progressDialog.setTitle("Upload in Progress ...");
       progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
       progressDialog.setMax(100);
       progressDialog.setProgress(0);
       progressDialog.show();
   }

    @Override
    protected Void doInBackground(String... params) {
        Cloudinary cloudinary = new Cloudinary(ObjectUtils.asMap(
                "cloud_name", "xxxxx",
                "api_key", "xxxxxxxxxxxx",
                "api_secret", "xxxxxxxxxxxxxxxxx"));
        try {
            cloudinary.uploader().upload(imgToUpload,
                    ObjectUtils.asMap("resource_type", "image"));
        } catch (IOException e) {
            e.printStackTrace();
        }


        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);
    }
}

}`

the stacktrace is:

03-14 08:44:13.179 14589-16685/net.we4x4.we4x4 E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: net.we4x4.we4x4, PID: 14589 java.lang.RuntimeException: An error occured while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:300) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355) at java.util.concurrent.FutureTask.setException(FutureTask.java:222) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: java.lang.RuntimeException: Missing required parameter - file at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:106) at com.cloudinary.Uploader.callApi(Uploader.java:22) at com.cloudinary.Uploader.upload(Uploader.java:55) at net.we4x4.we4x4.Upload$UploadTask.doInBackground(Upload.java:90) at net.we4x4.we4x4.Upload$UploadTask.doInBackground(Upload.java:69) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)  at java.lang.Thread.run(Thread.java:841) 

I am not sure if there is something wrong in my code ( syntax ) or i am missing something !?

ClassNotFoundException (Tomcat 7)

Hi,

I got this error while uploading image. Should i configure something at servlet xmls or download HttpClient source code.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at com.cloudinary.strategies.StrategyLoader.load(StrategyLoader.java:11)
    at com.cloudinary.strategies.StrategyLoader.find(StrategyLoader.java:20)
    at com.cloudinary.Cloudinary.loadStrategies(Cloudinary.java:74)
    at com.cloudinary.Cloudinary.<init>(Cloudinary.java:88)
    at CloudTest.<init>(CloudTest.java:19)
    at CloudTest.main(CloudTest.java:24)
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpUriRequest
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

Support for presigned urls

The readme doesn't elaborate if support for presigned URLs exists in this project.

I think if it doesn't then it would be good to add it and if does exist then it would be good to expose it and if it is already exposed then it would be good to document it :)

Sidenote: Someone suggested that since presigned URLs have an expiration time, they are useful when it comes to protecting my account bandwidth against a client with an image URL and a while loop!!! This sounds like a decent idea but I have reservations because I'm not sure what stops a client who received a presigned image URL from me ... From calling a PUT on that URL and changing the content? I don't see any granular differentiation for GET vs PUT/Post/Delete ... Am I missing something?

java.lang.RuntimeException: Stale request

Since a few days I am seeing this issue in our android application?

Any help is appreciated:

06-20 14:59:45.959  21560-22039/com.colibriapps.foodlr E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-3085
    Process: com.colibriapps.foodlr, PID: 21560
    java.lang.RuntimeException: Stale request - reported time is 2015-06-20 12:59:41 +0000 which is more than 1 hour ago
            at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:101)
            at com.cloudinary.Uploader.callApi(Uploader.java:22)
            at com.cloudinary.Uploader.upload(Uploader.java:55)
            at com.colibriapps.foodlr.controller.offer.OfferDishFragment.uploadImage(OfferDishFragment.java:1033)
            at com.colibriapps.foodlr.controller.offer.OfferDishFragment.access$500(OfferDishFragment.java:86)
            at com.colibriapps.foodlr.controller.offer.OfferDishFragment$15.run(OfferDishFragment.java:969)
            at java.lang.Thread.run(Thread.java:818)

Upgrade to Commons Lang3

And replace references from org.apache.commons.lang.StringUtils to org.apache.commons.lang3.StringUtils

Android library: Upload Raw files.

How do I upload a raw file to cloudinary using the android SDK? If I use the upload method, which works for images, it saves the file as an image(for a video).

I tried the uploadLargeRaw method, but getting errors.

java.lang.RuntimeException: Missing required parameter - file
at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:101)
at com.cloudinary.Uploader.callApi(Uploader.java:22)
at com.cloudinary.Uploader.uploadLargeRawParts(Uploader.java:116)
at com.cloudinary.Uploader.uploadLargeRaw(Uploader.java:75)
at com.cloudinary.Uploader.uploadLargeRaw(Uploader.java:59)

Upload API throws RuntimeException

Hello,

You should provide an easy way to handle upload errors in your SDK.

The method signature suggests that you will be throwing an IOException but looking at the source code, we can see that you're actually throwing RuntimeException in several cases ! These cases should be handled differently in the SDK so that the caller can identify them : they are definitely not a reason to throw a RuntimeException.

At the minimum, you should throw a IOException as specified by the upload signature.
Alternatively, you could think about a nicer error handling system, either with a custom Exception or with a specific Map returned (whose values should be documented !).

Uploader crash

This crash is caused by specific file name: "Universal Image Loader @#&=+-_.,!()~'%20.png"

 java.lang.StringIndexOutOfBoundsException: length=44; regionStart=41; regionLength=-17
     at java.lang.String.startEndAndLength(String.java:504)
     at java.lang.String.substring(String.java:1333)
     at java.net.DefaultFileNameMap.getContentTypeFor(DefaultFileNameMap.java:38)
     at java.net.URLConnection.guessContentTypeFromName(URLConnection.java:680)
     at com.cloudinary.android.MultipartUtility.addFilePart(MultipartUtility.java:91)
     at com.cloudinary.android.MultipartUtility.addFilePart(MultipartUtility.java:85)
     at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:67)
     at com.cloudinary.Uploader.callApi(Uploader.java:22)
     at com.cloudinary.Uploader.upload(Uploader.java:55)

Replace Map usage with OOP design classes

I am currently testing your service and evaluating to be your customer. But i am dissapointedd from the Java integration you provide.

Everywhere you pass generic Map instances holding String key value pairs for configuration, upload options / results. That is not suitable for an object oriented programming language, and looks like 15 years ago programming style (including underscores).

Also enumeration classes could be used for fixed parameters like transformations and meaningfull exceptions shall be thrown. To detect a resource not found exception one must check the generic message like if (e.getMessage().contains("Resource not found")).

That key-value and error message approach is very error prone and really not developer friendly.

Example:

String publicId = (String) uploadResult.get("public_id");

Could be:

String publicId = uploadResult.getPublicId();

Resume Upload & Upload callback

Hi,

I was performing Video upload via Signed Upload Strategy from my Android device. While I was trying all these stuff. I accidentally turned off my WiFi and the upload was failed. So, it would be great if we have a resume upload use case handled. Because every time its fail, I have to re trigger upload with new tokens. If this use case is already handled, please let me know the method name. I couldn't find any.

Moreover, I could not find API for upload callback. Its very hard / tidy watching the progress view rolling without letting the user know the progress report. Any help would be appreciable.

Thanks,
CP.

OutOfMemoryError while uploading videos

Issue: The SDK throws an OutOfMemoryError when I try to upload videos that are larger than 50MB in size
SDK Version: v1.2.2
Android Version: All versions
Device: All devices
Video file size: 65MB
Logs:

Throwing OutOfMemoryError "Failed to allocate a 2060 byte allocation with 1380 free bytes and 1380B until OOM"
		

FATAL EXCEPTION: RxIoScheduler-3
	Process: my.package.name, PID: 5028
         	java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
                 		   at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:59)
                             at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
                             at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                             at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152)
                             at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265)
                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                             at java.lang.Thread.run(Thread.java:818)
                          Caused by: java.lang.OutOfMemoryError: Failed to allocate a 2060 byte allocation with 1380 free bytes and 1380B until OOM
                             at com.android.okio.Segment.<init>(Segment.java:34)
                             at com.android.okio.SegmentPool.take(SegmentPool.java:48)
                             at com.android.okio.OkBuffer.writableSegment(OkBuffer.java:511)
                             at com.android.okio.OkBuffer.write(OkBuffer.java:424)
                             at com.android.okio.OkBuffer.clone(OkBuffer.java:740)
                             at com.android.okhttp.internal.http.RetryableSink.writeToSocket(RetryableSink.java:77)
                             at com.android.okhttp.internal.http.HttpConnection.writeRequestBody(HttpConnection.java:240)
                             at com.android.okhttp.internal.http.HttpTransport.writeRequestBody(HttpTransport.java:77)
                             at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:622)
                             at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:388)
                             at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:332)
                             at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:500)
                             at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
                             at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
                             at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:81)
                             at com.cloudinary.Uploader.callApi(Uploader.java:22)
                             at com.cloudinary.Uploader.upload(Uploader.java:55)
                             at my.package.name.common.utils.CloudinaryUtils.uploadMediaInternal(CloudinaryUtils.java:106)
                             at my.package.name.common.utils.CloudinaryUtils.lambda$uploadMedia$0(CloudinaryUtils.java:90)
                             at my.package.name.common.utils.CloudinaryUtils.access$lambda$0(CloudinaryUtils.java:0)
                             at my.package.name.common.utils.CloudinaryUtils$$Lambda$1.call(Unknown Source)
                             at rx.Observable.unsafeSubscribe(Observable.java:9860)
                             at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)
                             at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:221)
                             at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
                             at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) 
                             at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                             at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152) 
                             at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265) 
                             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
                             at java.lang.Thread.run(Thread.java:818) 

phash treatment mismatch between iOS and Android SDKs

We are using the "Safe mobile uploading" methods on Android and iOS as documented here, respectively:

https://github.com/cloudinary/cloudinary_java/tree/master/cloudinary-android#safe-mobile-uploading
https://github.com/cloudinary/cloudinary_ios#safe-mobile-uploading

Server-side, we use the scala library to create the signature string which looks something like this:

"notification_url=https://myserver.com/photo/notify&phash=1&timestamp=1437155198"

Notice that the value for "phash" is "1".

Using version 1.2.1 of the Android library, I am seeing a 401 error:

{
"error": {
"message": "Invalid Signature 25ed8e31b995bb927966616df2a42b979a2717f0. String to sign - 'notification_url=https://myserver.com/photo/notify&phash=true&timestamp=1437155198'."
}
}

Notice that the value for "phash" is "true", which is the root cause of the invalid signature.

Util.buildUploadParams() uses the Boolean.toString() value of phash to generate the signature string, which is either "true" or "false". We could change the server to use "true" instead of "1" and fix Android, however this will break the iOS implementation:

[CLUploader buildUploadParams] turns phash into an NSNumber whose stringValue is "1" or "0", not "true" or "false".

https://github.com/cloudinary/cloudinary_ios/blob/master/Cloudinary/CLUploader.m

This mismatch necessitates a branch on the server or subclassing the Uploader or CLUploader class on one of the clients to override buildUploadParams, both of which are hacky.

Please consider backwards compatibility when fixing this issue, otherwise it could break existing implementations.

Thanks!

Image Upload Error

Hi,I've been using the following code to upload images to Cloudinary and it has been getting runtime error below .(lib :android-1.2.1.jar core-1.2.1.jar)(java web server:wloudinary-http44 version:1.5.0) Please advise what could have done wrongly using below implementation.And i want to know that Is there an asynchronous upload method in the lib?

                                                                   Caused by: java.lang.RuntimeException: Server returned unexpected status code - 401 - {"error":{"message":"Invalid Signature 173f1b11b7ec9a7f67a0f61b83964db4aa32647e. String to sign - 'public_id=7f1f1a9422304b5d81d30f69f4577b96&timestamp=1.49019359024E12'."}}

Map config = new HashMap();
config.put("cloud_name", "tapplock");
mobileCloudinary = new Cloudinary(config);
mobileCloudinary.uploader().upload(new Bitmap2byte().Bitmap2Input(bitmap), finalObjectMap);

Transformation().streamingProfile No method found

The following Cloudinary documentation instructs to use the streamingProfile method on the Transformation class. This method is not available.

http://cloudinary.com/documentation/video_manipulation_and_delivery#adaptive_bitrate_streaming_hls_and_mpeg_dash

cloudinary.uploader().upload("big_buck_bunny.mp4", 
        ObjectUtils.asMap("resource_type", "video",
        "eager", Arrays.asList(
              new Transformation().streamingProfile("full_hd").format("m3u8"),
            "eager_async", true,
            "eager_notification_url", "http://mysite/notify_endpoint"
            "public_id", "bb_bunny"));

Im using 1.6 version of the cloudinary android library. Please help.

Cloudinary image upload (Invalid signaure issue)

I've been using the following code from the sample to upload images to Cloudinary and it has been working fine until one of the team member complains having issue uploading image using Android 5 device. Using simulator Android 5, I'm getting below runtime error. Please advise what could have done wrongly using below implementation.

java.lang.RuntimeException: Server returned unexpected status code - 401 - {"error":{"message":"Invalid Signature f11d48772281ea76f3fc49f25cb048ddef90a43d. String to sign - 'timestamp=1479686175'."}}

            Map config = new HashMap();
            config.put(KEY_CLOUD_NAME, BuildConfig.cloudinary_cloud_name);
            config.put(KEY_API_KEY, BuildConfig.cloudinary_api_key);
            config.put(KEY_API_SECRET, BuildConfig.cloudinary_api_secret);

            Cloudinary cloudinary = new Cloudinary(config);
            result = cloudinary.uploader().upload(fileToUpload, ObjectUtils.emptyMap());

404 not found error

The two links in the manual setup part of the page return a 404 not found error. Are they still required to use the api?

Cpu over head for generate in android

Hi,

I am using CloudinaryService generate to generate url in my android app, and while profiling. I found this computation too costly in terms of cpu cycle and it is blocking my main thread. Is there any way to optimise it.

CloudinaryService.getCloudinary().url().transformation(transformation.fetchFormat("auto")).generate(name);

In some cases it takes 100 of milli seconds to just generate an url.

screen shot 2016-04-24 at 2 02 22 pm

Error when Upload Picture

Try to upload a picture using:

    Map config = new HashMap();
    config.put("cloud_name", "xxx");
    config.put("api_key", "xxx");
    config.put("api_secret", "xxx-xxx");
    Cloudinary cloudinary = new Cloudinary(config);

    Map result  = cloudinary.uploader().upload("water.jpg", Cloudinary.emptyMap());

But I got an error:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Hex.encodeHexString([B)Ljava/lang/String;
at com.cloudinary.Cloudinary.apiSignRequest(Cloudinary.java:103)
at com.cloudinary.Cloudinary.signRequest(Cloudinary.java:119)
at com.cloudinary.Uploader.signRequestParams(Uploader.java:205)
at com.cloudinary.Uploader.callApi(Uploader.java:212)
at com.cloudinary.Uploader.upload(Uploader.java:71)
at com.hifu.app.CloudinaryTest.main(CloudinaryTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

How to delete folders via API?

In cloudinary-settings i have set "Auto-create folders" to "enabled".

When calling the method "deleteAllResources" via API, all images are going to be deleted, but empty folders are not deleted as well :(

But i also want to delete all the folders.

I tried:
cloudinary.api().deleteAllResources(ObjectUtils.emptyMap());

Get Video Thumnails

How can I get video thumbnails from uploaded video,
Currently, I called this api to get video thumbnails

String video = cloudinary.url().resourceType("video").imageTag(generateName(ProfileType.PROFILE_TYPE_VIDEO));

But it returns as below

<img src='http://res.cloudinary.com/toidv/video/upload/profile_438-video'/>

Please help to update document for this functionality! Thanks so much

Is the cloudinary API threadsafe?

Can I reuse the Cloudinary instance between threads? If so, would you mind documenting that with e.g. a @ThreadSafe annotation?

Thank you very much

Crash during upload

Hello,

I'm using your SDK in an Android Application to upload videos to my Cloudinary folder. I've included Fabric in my application and a crash from your SDK has been reported.

Enclosed is the report downloaded on Crashlytics. The report only includes info of one phone but it appeared on all Android versions that I support (minsdk to 4.4) with different manufacturers.

The crash doesn't seem to happen a lot. It must be an edge case.

Thanks

cloudinary_issue_29_crash_57eacabe012d00016963dc9b6b42e002.txt

Admin Api

Hello,

in ApiStrategy, the call method still contains
throw new Exception("not implemented");

Are you going to provide this feature?

Nothing is working.

Hi,
We downloaded the files and try to use as per instruction.
There is compilation error .Below code is mentioned in this page.

http://cloudinary.com/documentation/java_integration

There is compilation error in it.

import java.io.File;

import java.util.Map;

...

File toUpload = new File("daisy.png");

Map uploadResult = cloudinary.uploader().upload(toUpload);

We corrected the compilation error by using this code.

But it is still not working.

Map config = ObjectUtils.asMap(
"cloud_name", "my_cloud_name",
"api_key", "my_api_key",
"api_secret", "my_api_secret");
Cloudinary cloudinary = new Cloudinary(config);
Map result = cloudinary.api().resource("sample", ObjectUtils.emptyMap());

Upload not working on android with version 1.2.2

This is what I have tried so for,

              ` Cloudinary cloudinary = new Cloudinary();

               Map<String, String> config = new HashMap<>();

               config.put("cloud_name", "blabla");

               config.put("api_key", "blabla");

               config.put("api_secret", "blabla");

               Map callbacks = cloudinary.uploader().upload(inputStream, ObjectUtils.emptyMap());

                 if (callbacks != null && !callbacks.isEmpty()) {

                            String callbackUrl = (String) callbacks.get("public_id");

                             String callbackUrlToBeSaved = cloudinary.url().generate(callbackUrl);

                  }`

I get no callback url at all;
By the way I got the library via gradle in android studio with this dependency

compile 'com.cloudinary:cloudinary-android:1.2.2' and not through the individual .jar files.

Am I doing anything wrong? Please help.Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.