How to Upload File to Amazon S3 using from Ruby Application
You must be quite acquainted uploading files especially images S3 using Paperclip, CarrierWave, etc., gems. But what if you just want to upload a file without any kind of pre/post-processing or ActiveRecord integration? Paperclip, CarrierWave are great gems but it would be overkilling to use such gems where you need very limited functionality of the gem.
I recently need to upload the large number of xml to S3 in a microservice that doesn’t have DB integration. So that is the very clear case of using aws-sdk library directly overusing such flashy gems.
I tried googling around it and mostly landed on articles that were using the older version of aws-sdk API but I have to use latest one.
The latest version of aws-sdk(~> 2) had different API to upload a file to S3. So most of those example gives errors. I read docs and spec from the aws-sdk and come up with the working example.
Here is a quick gist which help you get going without stumbling and trying obsolete APIs.
At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.
Consulting is free – let us help you grow!
Choose Your Language
- Digital Marketing
- IT Consulting
- Project Management
- Salesforce Development