Module: MediaGallery::ImageProcessing

Defined in:
lib/media_gallery/image_processing.rb

Class Method Summary collapse

Class Method Details

.create_photo_file(data, photo_params) ⇒ Object

Helper method that processes a b64 encoded image and returns the equivalent binary object.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/media_gallery/image_processing.rb', line 7

def self.create_photo_file data, photo_params
  imageContent = Base64.decode64(data)
  tempfile = Tempfile.new("photoupload")
  tempfile.binmode
  tempfile << imageContent
  tempfile.rewind
  photo_params = photo_params.merge(:tempfile => tempfile)
  photo = ActionDispatch::Http::UploadedFile.new(photo_params)
  photo.original_filename = "photofile"
  photo
end