carrierwave

rails + carrierwave + fog + S3 socket error

吃可爱长大的小学妹 提交于 2019-12-18 14:54:24
问题 I'm having this problem trying to use S3 services with fog and the Jquery File Upload (https://github.com/blueimp/jQuery-File-Upload) The error Excon::Errors::SocketError (getaddrinfo: nodename nor servname provided, or not known (SocketError)): This occur when i try to call "save" method in the controller. I'm setting carrierwave as follow: config/initializers/carrierwave.rb CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => 'access_key

RESTful file uploads with CarrierWave

爷,独闯天下 提交于 2019-12-18 12:35:45
问题 I'm trying to build an API backend for file uploads. I want to be able to upload files with a POST request that has a Base64-encoded string of the file. The server should decode the string, and save the file using CarrierWave. Here's what I have so far: photo.rb: class Photo include Mongoid::Document include Mongoid::Timestamps mount_uploader :image_file, ImageUploader end image_uploader.rb: class ImageUploader < CarrierWave::Uploader::Base storage :file def store_dir "uploads/#{model.class

carrierwave - rails 3.1- undefined method: image_will_change

混江龙づ霸主 提交于 2019-12-18 12:14:41
问题 I get an error that look like this: undefined method `post_image_will_change!' for #<Post:0xf4e9184> app/controllers/posts_controller.rb:43:in `new' app/controllers/posts_controller.rb:43:in `create' I've included this in my "post" model: attr_accessible :title, :name, :content, :post_image mount_uploader :post_image, PostImageUploader and in _form.html.erb I've added: :html => { :multipart => true } I looked CarrierWave Error but that doesn't help me. Any clues of what generates that error?

Uploading multiple files at once to Rails app with Carrierwave (HTML5)

心不动则不痛 提交于 2019-12-18 12:00:45
问题 I'm close...very close...I'm able to upload single files just fine...but when i change the type of my form's file_field to :multiple => true so I can upload multiple images at once my uploaded files get wrapped in an array...and the 'magic' of 'accepts_nested_attributes_for` is lost. Edit: After more examination I wonder if I even need to bother with accepts_nested_attributes_for ? Perhaps I should just have a file_field, :multiple => true in my Gallery form (as opposed to a nested form) and

Uploading multiple files at once to Rails app with Carrierwave (HTML5)

天大地大妈咪最大 提交于 2019-12-18 12:00:15
问题 I'm close...very close...I'm able to upload single files just fine...but when i change the type of my form's file_field to :multiple => true so I can upload multiple images at once my uploaded files get wrapped in an array...and the 'magic' of 'accepts_nested_attributes_for` is lost. Edit: After more examination I wonder if I even need to bother with accepts_nested_attributes_for ? Perhaps I should just have a file_field, :multiple => true in my Gallery form (as opposed to a nested form) and

use base64 image with Carrierwave

馋奶兔 提交于 2019-12-18 11:18:10
问题 I want to perform the similar thing as from base64 photo and paperclip -Rails, but with Carrierwave. Could anybody explain me using of base64 images in Carrierwave? 回答1: class ImageUploader < CarrierWave::Uploader::Base class FilelessIO < StringIO attr_accessor :original_filename attr_accessor :content_type end before :cache, :convert_base64 def convert_base64(file) if file.respond_to?(:original_filename) && file.original_filename.match(/^base64:/) fname = file.original_filename.gsub(/^base64

How can I make carrierwave not save the original file after versions are processed?

痴心易碎 提交于 2019-12-18 03:36:45
问题 I'm using CarrierWave for my file uploads in Rails 3.1, and I'm looking for a way to save server space. Many of the photos being uploaded are upwards of 20MB, so after processing them down to 1024 x 1024, I would like to remove the original. Is there any easy way to do that in the uploader class? Thanks, --Mark 回答1: You could define an after_save callback in you model and delete the photo.. I dont know your model but something like this may work if you customize it: class User << ActiveRecord

How to make carrierwave delete the file when destroying a record?

瘦欲@ 提交于 2019-12-18 01:19:15
问题 I'm using the carrierwave gem to upload files. I have built a system for users to flag images as inappropriate and for admins to remove the images. From what I can tell, calling destroy on the image will only remove the path name from the table. Is there a way to have carrierwave actually remove the file itself? Or should rails automatically remove the file when I destroy the image path? 回答1: Not sure what CarrierWave offers for this, but you could use FileUtils in the Ruby standard library

Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden)

余生长醉 提交于 2019-12-17 22:37:25
问题 When I try to upload a picture to a "Car" object I'm denied access to S3. But the site images that are in the assets folder have displayed just fine since I added S3. The specific error that I get is this: 2015-02-17T14:40:48.459629+00:00 app[web.1]: Excon::Errors::Forbidden (Expected(200) <=> Actual(403 Forbidden) 2015-02-17T14:40:48.459630+00:00 app[web.1]: excon.error.response 2015-02-17T14:40:48.459635+00:00 app[web.1]: "Connection" => "close" 2015-02-17T14:40:48.459637+00:00 app[web.1]:

Rails 3. getting Errno::EACCES Permission Denied when uploading files on production

佐手、 提交于 2019-12-17 19:23:45
问题 The app works fine in development but in production I get Errno::EACCES Permission Denied error when I try to upload a file using Carrierwave. I'm sure it has something to do with permissions. How can I set the permissions to allow file uploads? pdf_uploader.rb def store_dir "#{Rails.root}/uploads/#{model.id}" end def cache_dir "#{Rails.root}/tmp/uploads/cache/#{model.id}" end 回答1: chmod -R 777 PATH_TO_APP/uploads chmod -R 777 PATH_TO_APP/tmp 回答2: As far as I know there are two things that