Skip to main content

Invalid JSON response from server

Comments

5 comments

  • Shirly Manor

    Hi Erwin,

     

    Can you please share the code that you are using for upload? Also, is it happen with any upload(also with image)?

    When I google it I found: https://stackoverflow.com/questions/4773663/jsonobject-text-must-begin-with

    Looking forward to your response,

    0
  • Erwin Tan

    Hi Shirly,

    here is my upload code.

    protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == SELECT_VIDEO && resultCode == RESULT_OK) {

    final Uri selectedVideo = data.getData();
    MediaManager.get()
    .upload(selectedVideo)
    .unsigned("1234")
    .option("resource_type", "video")
    .callback(new UploadCallback() {
    @Override
    public void onStart(String requestId) {
    progressBar.setVisibility(View.VISIBLE);
    Toast.makeText(MainActivity.this, "Upload Started...", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onProgress(String requestId, long bytes, long totalBytes) {
    //Double progress = (double) bytes/totalBytes * (1024*1024);
    //Toast.makeText(MainActivity.this, String.valueOf(progress), Toast.LENGTH_SHORT).show();

    }

    @Override
    public void onSuccess(String requestId, Map resultData) {

    Toast.makeText(MainActivity.this, "Uploaded Successfully", Toast.LENGTH_SHORT).show();
    progressBar.setVisibility(View.GONE);
    uploadBtn.setVisibility(View.INVISIBLE);

    String publicId = resultData.get("public_id").toString();

    gifUrl = MediaManager.get().url().resourceType("video")
    .transformation(new Transformation().videoSampling("25")
    .delay("200").height(200).effect("loop:10").crop("scale"))
    .resourceType("video").generate(publicId + ".gif");


    Glide.with(getApplicationContext()).asGif().load(gifUrl).into(img1);

    download_btn.setVisibility(View.VISIBLE);

    }

    @Override
    public void onError(String requestId, ErrorInfo error) {

    Toast.makeText(MainActivity.this, "Upload Error", Toast.LENGTH_SHORT).show();
    Log.v("ERROR!!", error.getDescription());
    }

    @Override
    public void onReschedule(String requestId, ErrorInfo error) {

    }

    }).dispatch();
    } else {

    Toast.makeText(MainActivity.this, "Can't Upload", Toast.LENGTH_SHORT).show();
    }
    }
    0
  • Aditi Madan

    Hi Erwin,

    Thanks for sharing the code. Could you also share your cloud name and upload preset.

    Are you uploading the video from your phone's file system or are you passing a direct URL?

    Can you please open a support ticket here: https://support.cloudinary.com/hc/en-us/requests/new and share the above information.

    Regards,
    Aditi

    0
  • Odera Dim

    Was there a resolution to this?

    0
  • Aleksandar Kostadinov

    Hi,

    For the issue raised by Erwin, we received a direct ticket about that on which we responded with some details from our logs based on the upload history on the account and asked for additional information. However, since that, we didn't receive any response.

    If you're running into this issue, please submit a ticket to us using the link Aditi shared above and share with us the code you are using to upload and an example upload request (such as filename + time of upload) and we can check our logs on our side to begin investigating this.

    0

Post is closed for comments.