Skip to main content
Question

Chunk File Uploads via Ruby on Rails: Examples?

  • May 22, 2025
  • 2 replies
  • 3 views

Forum|alt.badge.img

I'm trying to implement the Chunk File Upload via a Ruby on Rails application and I'm having a few difficulties.

 

1.  What methods are other developers using to split the document files into separate chunks for uploading?  I'm trying to use `IO.binread(file, length, offset)` but that seems less than performant.

 

2.  When I try to upload the file parts I've created via the previously mentioned `IO.binread()`, even if the file sizes say they are exactly what Box is expecting, I receive a "413 Request Entity` error saying I've went over the size limit.  

 

If anyone has successfully implemented this in Ruby on Rails and has either some pointers or a repo I can look at to see how you organized things I'd really appreciate it!

2 replies

Forum|alt.badge.img

Further info:

 

Using Postman (and within my app) I get the following extended error response to the 413 Request Entity Too Large:
 
{
    "code": "request_size_too_long",
    "message": "Request size 16777434 exceeds max of 1000000",
    "request_id": HIDDEN
}
 
However, below is the response that I got from the Create Session endpoint for this file.  So the size being suggested by the Create Session endpoint isn't being accepted as valid.  Any clues?
 

{"total_parts"=>4,

 "part_size"=>16777216,

 "session_endpoints"=>

  {"list_parts"=>"https://upload.box.com/api/2.0/files/upload_sessions/REMOVED/parts",

   "commit"=>"https://upload.box.com/api/2.0/files/upload_sessions/REMOVED/commit",

   "log_event"=>"https://upload.box.com/api/2.0/files/upload_sessions/REMOVED/log",

   "upload_part"=>"https://upload.box.com/api/2.0/files/upload_sessions/REMOVED",

   "status"=>"https://upload.box.com/api/2.0/files/upload_sessions/REMOVED",

   "abort"=>"https://upload.box.com/api/2.0/files/upload_sessions/REMOVED"},

 "session_expires_at"=>"2018-02-01T18:51:41Z",

 "id"=>"REMOVED",

 "type"=>"upload_session",

 "num_parts_processed"=>0}


Forum|alt.badge.img

Double check your request is PUT not POST!