Using the File Upload API in Ruby on Rails
The documentation surrounding the File Upload API is somewhat unclear as to what Box is expecting the file to be passed as. Previously we were using the Box View API where you just had to supply the URL to the file but that doesn't seem to be the case anymore.
If we're unable to pass just the file URL, can you give us a little insight on how you'd pass a "file object" in Rails in a way that the API will accept because we're up against the EOL deadline on Monday and need to get this functional ASAP.
Even just a link to a good explanation/tutorial would be great, its late at night for me and my Google skills are failing me completely right now.
Thank you!
-
Hi , thanks for your post! Sorry to hear about the trouble!
You're right, the behavior for uploading files has changed from the View API to the New Box View (NBV) API. In the legacy View, developers could supply a remote URL for us to "fetch" OR upload a file from a local location. In the NBV, the upload behavior is now aligned (and uses the same endpoint as) Box's larger Content API. You'll need to supply the file directly:
https://developer.box.com/reference#upload-a-file
For a ruby-specific example, I looked to our Ruby SDK and found this example:
https://github.com/cburnette/boxr#a-quick-example
For Authentication, since the NBV does not use Standard OAuth2 or OAuth2 with JWT, instead favoring a longer lived token, you can create a client like you would with the "Developer Token" mentioned here (but your NBV token is long-lived, so you don't have to worry about the 60 min expiration):
https://github.com/cburnette/boxr#creating-a-client
The Ruby SDK was designed for our content API, but the endpoints called are the same as those in the NBV. It's just that the endpoints supported are pared down (see endpoints supported...):
https://developer.box.com/v2.0/docs/getting-started-with-new-box-view
The other notable difference is the level of customization available to how you want to design your Preview experience. This is a good guide to show you the difference:
https://developer.box.com/v2.0/docs/using-box-preview-in-your-application
Best regards,
Jason
Please sign in to leave a comment.
Comments
1 comment