Invalid JSON response from server

Comments

3 comments

  • Avatar
    Shirly

    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
    Comment actions Permalink
  • Avatar
    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
    Comment actions Permalink
  • Avatar
    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
    Comment actions Permalink

Please sign in to leave a comment.