How to create sketches using a carrier after loading the source file directly to s3 with loading the jquery file

I upload an image via jquery_file_upload (Railscast episode # 383) The upload works fine and I get the url in the callback function

The problem is this: I want to create some thumbnails after uploading directly to s3

for this I assume:

  • Server must read image from s3
  • Server needs to create thumbnails
  • The server must store thumbnails directly in s3
  • The server should receive a callback and display the thumbnails accordingly.
  • The server must save the field created by the thumbnails.

Now, after completing the image, to load the image controller callback:

def create #get the url from the callbcack #eg: image[image_source] = https://<BUCKET>.s3.amazonaws.com/uploads/myimage.png @image = Image.new(params[:image]) @image.user_id = current_user.id @image.save end 

And the model:

 class Image < ActiveRecord::Base attr_accessible :image_thumb, :user_id, :width ,:album_type_id after_save :enqueue_image mount_uploader :image_thumb, ImageUploader def enqueue_image #checking if i have the original image if self.image_source present? #what to do here? #how can i call the carrierwave function to create the thumbnails? #how to send the thumbnails directly to s3 with callback name? end end end 
+4
source share
1 answer

Do I need to create thumbnails after loading? If not, I think you can create a thumbnail (or as many as you want) at boot time using version . Example:

  class ImageUploader < CarrierWave::Uploader::Base version :thumb do process :resize_to_fill => [50, 50] end end 
0
source

Source: https://habr.com/ru/post/1438248/


All Articles