lib/fleximage/model.rb
# Write image to file system/S3 and cleanup garbage.
Write image to file system/S3 and cleanup garbage.
Write image to file system / S3 and cleanup garbage .
def post_save
          if @uploaded_image
            if self.class.file_store?
              FileUtils.mkdir_p(directory_path)
              @uploaded_image.write(file_path)
            elsif self.class.s3_store?
              blob = StringIO.new(@uploaded_image.to_blob)
              AWS::S3::S3Object.store("#{id}.#{self.class.image_storage_format}", blob, self.class.s3_bucket)
            end
          end
          delete_temp_image
          if @uploaded_image
            GC.start
          end
        end
def post_save if @uploaded_image if self . class . file_store? FileUtils . mkdir_p ( directory_path ) @uploaded_image . write ( file_path ) elsif self . class . s3_store? blob = StringIO . new ( @uploaded_image . to_blob ) AWS :: S3 :: S3Object . store ( "#{id}.#{self.class.image_storage_format}" , blob , self . class . s3_bucket ) end end delete_temp_image if @uploaded_image GC . start end end
Write image to file system/S3 and cleanup garbage.
Write image to file system / S3 and cleanup garbage .
# Make sure target directory exists # Write master image file # Cleanup temp files # Start GC to close up memory leaks