cloudinary / cloudinary_android

Android client for integrating with Cloudinary
MIT License
67 stars 59 forks source link

RuntimeException: Invalid Content-Range header when device locale is set to arabic #57

Open omjimehrotra opened 6 years ago

omjimehrotra commented 6 years ago

Here is the error stack trace.

E/DefaultRequestProcessor: Unexpected exception for request ff49ae42-aed4-463b-96c2-c4a1d875d8cc. java.lang.RuntimeException: Invalid Content-Range header at com.cloudinary.android.UploaderStrategy.callApi(UploaderStrategy.java:143) at com.cloudinary.Uploader.callApi(Uploader.java:34) at com.cloudinary.Uploader.uploadLargeParts(Uploader.java:212) at com.cloudinary.Uploader.uploadLarge(Uploader.java:143) at com.cloudinary.android.DefaultRequestProcessor.doProcess(DefaultRequestProcessor.java:197) at com.cloudinary.android.DefaultRequestProcessor.processRequest(DefaultRequestProcessor.java:89) at com.cloudinary.android.MediaManager.processRequest(MediaManager.java:367) at com.cloudinary.android.AndroidJobStrategy$UploadJob.onRunJob(AndroidJobStrategy.java:203) at com.evernote.android.job.Job.runJob(Job.java:109) at com.evernote.android.job.JobExecutor$JobCallable.runJob(JobExecutor.java:151) at com.evernote.android.job.JobExecutor$JobCallable.call(JobExecutor.java:136) at com.evernote.android.job.JobExecutor$JobCallable.call(JobExecutor.java:119) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

d-mendoza commented 6 years ago

Hi @omjimehrotra,

To better assist in diagnosing this issue, can you provide us with the following:

  1. The upload command use
  2. The parameters passed into the upload call
omjimehrotra commented 6 years ago

Hi @d-mendoza

Here is my cloudinary upload command:

MediaManager.get().upload(filePath).callback(uploadCallback) .unsigned(AppConstants.CLOUDINARY_UPLOAD_PRESET) .option("resource_type", "auto") .dispatch();

d-mendoza commented 6 years ago

@omjimehrotra Thank you for pointing this out! Our team is looking into it.

MaxBayne commented 6 years ago

@d-mendoza

any help or fix for this bug

thanks

d-mendoza commented 6 years ago

@MaxBayne It's on our dev teams todo list. I'll update when we'll have any insights.

omjimehrotra commented 6 years ago

Any Update on this issue?

MaxBayne commented 6 years ago

no still issue

On 5/11/18, omjimehrotra notifications@github.com wrote:

Any Update on this issue?

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/cloudinary/cloudinary_android/issues/57#issuecomment-388273815

yakirp commented 6 years ago

Hi guys, I hope that we will fix this issue soon, I will update.

dlhck commented 6 years ago

any update on this one? Getting this bug also with other locales ..

shaktisinh commented 5 years ago

make sure your file length is not 0

Siddharthflo commented 5 years ago

Any update on this issue? I am facing the same issue with Indian languages(Marathi/mr)

igy commented 5 years ago

Hi all, and especially to Siddarth who posted today- If you're still seeing this issue, may I ask which version of the SDK you're using and for an updated example?

This issue is still open at the moment but I've checked with the SDK team and we believe this may be resolved in v1.24.1 or later of our Android SDK due to changes in the underlying Java library, the version of which was updated in #67.

This was a change which forced the en-US locale for the chunked upload calls which should have worked around the issue here

Siddharthflo commented 5 years ago

Hi igy, Currently, I am using v1.24.0

igy commented 5 years ago

Hi Siddarth - can you please try with v1.24.1? Or preferably with the current version, v1.26.0 ?

luke537 commented 4 years ago

I've tried using version 1.24.1 and 1.26.0 and I'm still having this issue, even if I try to change to locales such as en-US. Is there any solution for this yet? My code is: String requestId = MediaManager.get().upload(photoUri).unsigned(CLOUD_PRESET).option("resource_type", "auto").dispatch();

Would really appreciate some help with this as the library is unusable for me with this issue. Thanks.

idobarnoam commented 4 years ago

@luke537 The fix was introduced on 1.24.1, and from my understanding from the thread, it works for @Siddharthflo as well.

Are you not able to upload anything to Cloudinary, regardless of the locale? Could you share the flow that you are doing when you are getting this error? Also could you share the Android version?

luke537 commented 4 years ago

@idobarnoam Currently, I am not able to upload anything to Cloudinary from Android. Please see my flow below:

public class MyFragment extends Fragment {
...
...
private void dispatchTakePictureIntent() {
        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        // Ensure that there's a camera activity to handle the intent
        if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
            // Create the File where the photo should go
            try {
                photoFile = createImageFile();
            } catch (IOException ex) {
                // Error occurred while creating the File
            }
            // Continue only if the File was successfully created
            if (photoFile != null) {
                photoUri = FileProvider.getUriForFile(getContext(),
                        "com.example.fypapplication_waster.fileprovider",
                        photoFile);
                startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
            }
        }
    }

    private File createImageFile() throws IOException {
        // Create an image file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
        String imageFileName = "JPEG_" + timeStamp + "_";
        File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
        File image = File.createTempFile(
                imageFileName,  /* prefix */
                ".jpg",         /* suffix */
                storageDir      /* directory */
        );

        return image;
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == REQUEST_TAKE_PHOTO) {
            if (resultCode == RESULT_OK) {
                //Upload file to cloudinary
                String requestId = MediaManager.get().upload(photoUri).unsigned(PRESET_NAME).option("resource_type", "auto").dispatch();

            } else if (resultCode == RESULT_CANCELED) {
                // User cancelled the image capture
            }
        }
    }
}

Basically, all I'm doing is taking a photo and passing the URI of the photo to Cloudinary to upload.

Here are the Android versions: minSdkVersion 19 targetSdkVersion 29 Please let me know if you need anything else from me

luke537 commented 4 years ago

@idobarnoam @yakirp Hi, is there any update on this?

idobarnoam commented 4 years ago

@luke537 Sorry for the response delay.

What I'm understanding is that currently, no upload is possible on your project regardless of locale.

Is that the case? Are you getting the error that is noted on the thread 's subject or a different one?

I'm asking since if you can't upload at all it might be a different issue not related to locale so it might be best to open a request at support@cloudinary.com with the relevant details. This would also allow faster replies and resolutions.

darothub commented 4 years ago

Hi, is there any update on this?

idobarnoam commented 4 years ago

Hi @darothub Could you elaborate on what it is you are experiencing? I'm asking since the issue in the subject was handled on version 1.24.1.

darothub commented 4 years ago

Ok. I was trying to upload an image from android studio. I used the manifest config file to initialized MediaManager. Then the following

MediaManager.init(requireContext)
MediaManager.get().upload(uri/path)
    .unsigned("sample_app_preset")
    .dispatch()

and all I get is Invalid Content Range header error I am currently using version 1.27.0.

Sincerely, I have since moved to firebase but thought Cloudinary would be handy

aditimadan-Cloudinary commented 4 years ago

@darothub Can you please share the original file you tried uploading? Was it taken through the camera or uploaded from a local file system? If you could also share your cloud name I will be able to check the logs. You can always raise a support ticket here: https://support.cloudinary.com/hc/en-us/requests/new if privacy is a concern.

darothub commented 4 years ago

Hi @aditimadan-Cloudinary sorry for the late response. Yes the image is taken through the camera and a local file system. Currently I'm using my personal account(cloud name: carflux) for test. It turns out we are still interested in using Cloudinary. So we will getting a paid storage if all works well. Find the image url below: https://firebasestorage.googleapis.com/v0/b/anap-covid-app.appspot.com/o/images%2Freport_Abia%20_20200517_175729_.jpg?alt=media&token=43ce3bc7-4dee-413d-9197-7c7c9b08cb92

michalkcloudinay commented 4 years ago

Hi @darothub, Can you please check and tell us what is the device current language? You can find how to do that here: https://stackoverflow.com/questions/4212320/get-the-current-language-in-device

darothub commented 4 years ago

@michalkcloudinay Apologies once again for replying late. I have been handling a lot but still need to use your service. The device current language is English. Thanks in anticipation

darothub commented 4 years ago

@michalkcloudinay @aditimadan-Cloudinary We have purchased the official cloudinary account for our application. Any update on this issue?

michalkcloudinay commented 4 years ago

@darothub In order to investigate your issue, can you please open a ticket here: https://support.cloudinary.com/hc/en-us/requests/new?