2

Recently I have been working on an app and it requires the files on the phone to be uploaded to the server. These file may be either images or videos. I used ASyncTask to do the networking on the background.

However if the file size is greater than 45 MBs the file upload fails...it works just fine other-wise

What should I use instead of Async Tasks? Should I go for Sync Adapters or for the Volley library? I know nothing in either of these.

eleven
  • 6,779
  • 2
  • 32
  • 52
prateek_cs_2012
  • 55
  • 1
  • 10
  • IMO, you should read the answer at [How do I upload large files (10MB) in Android?](http://stackoverflow.com/questions/28575279/how-do-i-upload-large-files-10mb-in-android) – BNK Aug 31 '15 at 03:42
  • By using Volley you should avoid uploading large files. Check http://www.codicode.com/art/upload_files_from_android_to_a_w.aspx – Subhalaxmi Aug 31 '15 at 04:49

2 Answers2

1

You can use retrofit typedfile approach to upload file in multi-part.

For your reference : https://futurestud.io/blog/retrofit-how-to-upload-files/

lakshay
  • 1,018
  • 2
  • 18
  • 30
  • 3
    For everyone using Retrofit 2.0. The process to upload files changed quite a bit. There is a special guide for it: https://futurestud.io/blog/retrofit-2-how-to-upload-files-to-server/ – peitek Nov 10 '15 at 14:57
0

What response do you get from the server when the upload fails? Understanding the response can help you get insight into why the upload is failing. One possibility is that the server you are trying to upload file to is not configured to handle that big payload in which case you will get the following HTTP response.

HTTP Error 413 Request entity too large

HTTP Error 413

However this is just one of the possibilities. I suggest you to inspect HTTP response and it's other properties.

Sudip Bhandari
  • 2,165
  • 1
  • 27
  • 26