What is the limit size of file upload (mp4 video) when using Okhttp in Android? -


i trying upload video file ruby on rails backend. using okhttp this.

it working when less mb files uploaded. large files, not working , entering block

@override public void onfailure(request request, ioexception e) { // handle error log.d(tag, "video upload request failed" + request.body().tostring() + "error = " + e.getmessage()); } 

curious thing error when printed comes null

i have tried upload 60 mb file using postman using same api , worked beautifully. no issues server end.]

here code reference :

 private static final mediatype media_type_png = mediatype.parse("video/mp4");  public static boolean uploadvideoonserver(final context mcontext, final video video) {      final okhttpclient client = new okhttpclient();     client.setconnectionpool(new connectionpool(0, 60000));      string url = constants.url_memory_upload + tjpreferences.getactivejourneyid(mcontext) + "/videos";      try {         requestbody requestbody = new multipartbuilder()                 .type(multipartbuilder.form)                 .addformdatapart("video[video_file]", "file",                         requestbody.create(media_type_png, new file(video.getvidlocalurl())))                 .addformdatapart("video[user_id]", video.getcreatedby().getidonserver())                 .addformdatapart("api_key", tjpreferences.getapikey(mcontext))                 .addformdatapart("video[latitude]", string.valueof(video.getplacetaken().getlatitude()))                 .addformdatapart("video[longitude]", string.valueof(video.getplacetaken().getlongitude()))                 .addformdatapart("video[caption]", video.getcaption())                 .addformdatapart("video[created_at]", string.valueof(video.getcreatedat()))                 .addformdatapart("video[updated_at]", string.valueof(video.getupdatedat()))                 .build();          request request = new request.builder()                 .url(url)                 .post(requestbody)                 .build();          client.newcall(request).enqueue(new callback() {              @override             public void onfailure(request request, ioexception e) {                 // handle error                 log.d(tag, "video upload request failed" + request.body().tostring() + "error = " + e.getmessage());             }              @override             public void onresponse(com.squareup.okhttp.response response) throws ioexception {                 if (!response.issuccessful()) {                     // handle error                  }                 // upload successful                 log.d(tag, "video upload request successful response = " + response.body().tostring());                 } catch (jsonexception e) {                     e.printstacktrace();                 }             }         });          return true;     } catch (exception ex) {         // handle error     }     return false; } 


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -