Thumbnails with carrierwave_direct or s3_direct_upload - ruby-on-rails

Is it possible to generate thumbnails using carrierwave_direct or s3_direct_upload uploading an image direct to amazon s3? I'm with a problem and didn't found the best solution for me yet. I need image thumbnails, my amazon server has a timeout and I can't send large files to my application and sending directly I did not found any way to make thumbs. I'm thinking about limit the image size before upload, have I any other options?

Related

How to implement AWS S3 Multipart Upload with Rails and Active Storage?

I'm using vanilla Rails Active Storage file upload with multiple:true option. The files are stored on S3. The setup is working well. However, I was thinking for very large files it would be beneficial to implement Multipart Upload for optimal speed and reliability.
I found a description of AWS S3 multipart upload here: https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html
I also found a Ruby specific page: https://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu-ruby-sdk.html
However, I couldn't find any reference on how to implement this feature with Rails and Active Storage.
I would like to receive some direction on how best to go about implementing multipart upload without ripping out Active Storage if possible.
In case somebody is looking for an answer on this. Active Storage will support multipart upload starting from Rails 6.1. Active Storage direct upload automatically switches to multipart for large files. No settings changes are required.
You can customise the threshold for what is considered a large file. The default is 100MB, and you can change the default by adding this to your storage.yml under the amazon settings:
upload:
multipart_threshold: <%= 250.megabytes %>
Reference: https://github.com/rails/rails/blob/master/activestorage/CHANGELOG.md

Is it possible to upload directly without touching my server?

Is it possible to use carrier wave to upload directly to amazon's S3 without using my server?
What i mean is, I don't want the images first going to my ec2 instance, and then uploaded to s3. I believe there is a way to upload directly to S3 to save my server's resources from having to process/stream the file.
I am just looking into carierwave, does it support nice html5 uploads where the user can just drag and drop the file on the web page?
If you want to upload directly to S3 from the browser you must do it with Javascript.
Heroku provides a nice tutorial : https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-rails
Once uploaded, you can pass the finale S3 public URL of the image in a hidden field and download it server-side with carrierwave for further manipulation (resizing, ...)

How to speed up image uploading carrierwave and Rails4

I am working with Rails4 and carrierwave, uploading the images and files to S3. But it's taking much time and very slow. How to handle this situation to speed up the server speed!!!
How to handle this using Background Jobs and Handle request from lot of users.
Also getting images is very slow into my application!!!
Can you suggest me how to achieve Rails severe works fast while uploading files?
You might consider uploading directly from the client to S3 via Ajax. This would nearly completely take your server out of the mix.
Uploading Image to Amazon s3 with HTML, javascript & jQuery with Ajax Request (No PHP)
This is a well documented concept elsewhere online.
Amazon S3 now has notifications for newly created objects.
http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
You could drop the upload notifications into an Amazon SQS queue. You could then use a gem like Fog to create a background worker to pull events off the queue to create or update records in the database to reflect the newly completed upload.
https://github.com/fog/fog
Regardless of the solution, if you're uploading big files, it's likely your local network's upload speed that is the bottleneck.

Carrierwave, Fog and URL Rewriting

I'm storing images in Amazon S3 using Fog and Carrierwave. It returns a url like bucket.s3.amazonaws.com/my_image.jpg.
DNS entries have been set up so that images.mysite.com points to bucket.s3.amazonaws.com.
I want to adjust my views an APIs to use the images.mysite.com/my_image.jpg URL. Carrierwave, however, only spits out the Amazon based one. Is there a simple way to tell Carrierwave and/or Fog to use a different host for its URLs than normal? If not, how would I modify the uploader to spit it out?
Come to find out that, as of June 6th, 2012, Amazon AWS does not support custom SSL certs, which makes this a moot point.

how to get bytes loaded to server using rails paperclip gem?

i am using paperclip gem to upload images on the server side, i need to get updated with the bytes loaded on server through the upload process.
my aim is to update the progress bar accordingly. how do I do this?
You can only do this by using a Flash-based uploading tool which has direct access to the file and the upload stream. Just integrate it with Paperclip (and there are a ton of examples on google showing how to)
I would recommend one of these:
http://plupload.com/
http://www.uploadify.com/

Resources