Uploading images to IMGUR using Volley returns TimeoutError

Manny265

I am trying to upload an image to my Imgur account using Volley StringRequest. I am not sure how to handle the response so what happens is it keeps re uploading since it hasnt received a response from Imgur. The image ends up being uploaded a couple of times until the TimeoutError is thrown. How can I ensure this does not happen as I cannot detect the response being returned from the Imgur server?
Here is the method I am using to upload the image after converting it to Base64:

 public void uploadImage(View view) {
    Log.i(TAG,"start upload");
    StringRequest uploadRequest = new StringRequest(Request.Method.POST, AppConst.IMGUR_ADD_IMG, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            Log.d(TAG, "finished image upload");
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e(TAG, error.toString());
            Log.e(TAG,"finish/error upload");
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> headers = new HashMap<>();
            headers.put("Authorization", "Bearer " + token);
            return headers;
        }

        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put(AppConst.IMGUR_TAG_IMAGE, encodeImage(selectedImg));
            params.put(AppConst.IMGUR_TAG_TITLE, "title");
            params.put(AppConst.IMGUR_TAG_NAME, String.valueOf(System.currentTimeMillis()));
            return params;
        }
    };

    AppController.getInstance().addToRequestQueue(uploadRequest);

}
Submersed

Change the DefaultRetryPolicy on the Request to have a larger expiration time frame, since uploading an image can take a bit. Also, for the double upload, make sure to have max_retries set to 0.

new DefaultRetryPolicy(LONGER_TIMEOUT, 0, 0);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Uploading image using pyimgur to imgur, using images link

From Dev

Uploading multiple images with volley?

From Dev

Uploading image to Imgur using AngularJS

From Dev

PHP: Uploading multiple images to imgur at once

From Dev

Is Volley framework in Android is suitable for uploading images and videos?

From Dev

Android: uploading user images to server (Volley/Blob)

From Dev

Uploading Multiple Images using CarrierWave

From Dev

Uploading images using Servlet 3.0

From Dev

Uploading images using Servlet 3.0

From Dev

Uploading Images in laravel using Intervention

From Dev

Caching text and images using Volley library

From Dev

Uploading images to mysql using php form

From Dev

Uploading images to a Google Spreadsheet using Apps Script

From Dev

Uploading images to database using the BLOB throwing exception

From Dev

Uploading multiple images in webservice using PHP

From Dev

Uploading multiple images using SRWebClient in Swift

From Dev

Uploading images to database using the BLOB throwing exception

From Dev

Uploading large images using Retrofit 2

From Dev

Accessing imgUr thru OAuth (uploading to user account)

From Dev

uploading to imgur, have failed for a week now

From Dev

Firefox addon uploading canvas contents to imgur

From Dev

How can I get imgur.com album images using ajax request

From Dev

Xampp php permission denied when trying to post images using imgur api?

From Dev

Android Volley ListView Images Not Loading When Using DiskBasedCache

From Dev

Android Volley ListView Images Not Loading When Using DiskBasedCache

From Dev

how to get images from json in listview using volley

From Dev

rhc setup returns "warning: constant ::TimeoutError is deprecated"

From Dev

rhc setup returns "warning: constant ::TimeoutError is deprecated"

From Dev

Uploading an array of images using AFNetworking 2 Batch requests

Related Related

  1. 1

    Uploading image using pyimgur to imgur, using images link

  2. 2

    Uploading multiple images with volley?

  3. 3

    Uploading image to Imgur using AngularJS

  4. 4

    PHP: Uploading multiple images to imgur at once

  5. 5

    Is Volley framework in Android is suitable for uploading images and videos?

  6. 6

    Android: uploading user images to server (Volley/Blob)

  7. 7

    Uploading Multiple Images using CarrierWave

  8. 8

    Uploading images using Servlet 3.0

  9. 9

    Uploading images using Servlet 3.0

  10. 10

    Uploading Images in laravel using Intervention

  11. 11

    Caching text and images using Volley library

  12. 12

    Uploading images to mysql using php form

  13. 13

    Uploading images to a Google Spreadsheet using Apps Script

  14. 14

    Uploading images to database using the BLOB throwing exception

  15. 15

    Uploading multiple images in webservice using PHP

  16. 16

    Uploading multiple images using SRWebClient in Swift

  17. 17

    Uploading images to database using the BLOB throwing exception

  18. 18

    Uploading large images using Retrofit 2

  19. 19

    Accessing imgUr thru OAuth (uploading to user account)

  20. 20

    uploading to imgur, have failed for a week now

  21. 21

    Firefox addon uploading canvas contents to imgur

  22. 22

    How can I get imgur.com album images using ajax request

  23. 23

    Xampp php permission denied when trying to post images using imgur api?

  24. 24

    Android Volley ListView Images Not Loading When Using DiskBasedCache

  25. 25

    Android Volley ListView Images Not Loading When Using DiskBasedCache

  26. 26

    how to get images from json in listview using volley

  27. 27

    rhc setup returns "warning: constant ::TimeoutError is deprecated"

  28. 28

    rhc setup returns "warning: constant ::TimeoutError is deprecated"

  29. 29

    Uploading an array of images using AFNetworking 2 Batch requests

HotTag

Archive