Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
omjimehrotra opened this issue Apr 13, 2018 · 28 comments
Assignees

Comments

@omjimehrotra
Copy link

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
Copy link

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

@d-mendoza d-mendoza self-assigned this Apr 13, 2018
@omjimehrotra
Copy link
Author

omjimehrotra commented Apr 14, 2018

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
Copy link

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

@MaxBayne
Copy link

@d-mendoza

any help or fix for this bug

thanks

@d-mendoza
Copy link

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

@d-mendoza d-mendoza reopened this Apr 30, 2018
@omjimehrotra
Copy link
Author

Any Update on this issue?

@MaxBayne
Copy link

MaxBayne commented May 12, 2018 via email

@yakirp
Copy link
Contributor

yakirp commented May 13, 2018

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

@dlhck
Copy link

dlhck commented Oct 5, 2018

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

@shaktisinh
Copy link

make sure your file length is not 0

@Siddharthflo
Copy link

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

@igy
Copy link

igy commented Mar 12, 2019

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
Copy link

Hi igy,
Currently, I am using v1.24.0

@igy
Copy link

igy commented Mar 13, 2019

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

@luke537
Copy link

luke537 commented Feb 29, 2020

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
Copy link

idobarnoam commented Mar 1, 2020

@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
Copy link

luke537 commented Mar 2, 2020

@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
Copy link

luke537 commented Mar 4, 2020

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

@idobarnoam
Copy link

@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
Copy link

Hi, is there any update on this?

@idobarnoam
Copy link

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
Copy link

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
Copy link

@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
Copy link

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
Copy link

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
Copy link

@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
Copy link

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

@michalkcloudinay
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests