carrierwave

how to reload page after uploading images

我与影子孤独终老i 提交于 2020-01-03 03:25:07
问题 I use gem 'jquery-fileupload-rails' and 'carrierwave_backgrounder' gem with sidekiq. How to add reload the page after download is complete? The problem is that the download is in the background and the page is reloaded immediately, not when the images loaded fileupload.js $(function () { $('#new_photo').fileupload({ acceptFileTypes: '/(\.|\/)(gif|jpe?g|png)$/i', dataType: 'html', add: function (e, data) { data.context = $('#loading').css({display:"block"}).appendTo('#photos'); data.submit();

Show Rails Carrierwave URL without exposing entire path

早过忘川 提交于 2020-01-02 10:33:17
问题 I'm making a webapp with paid downloads, and I followed Carrierwave's guide for protecting uploads. Everything is working as expecting save one thing. Here's my current setup: Product File Uploader ... def store_dir "#{Rails.root}/downloads/#{model.product_id}/#{model.id}" end ... Routes get "/downloads/:product_id/:product_file_id/:filename", :controller => "products", action: "download", conditions: {method: :get} ProductsController def download product_file = ProductFile.find(params[

Carrierwave and s3 with heroku error undefined method `fog_credentials='

[亡魂溺海] 提交于 2020-01-01 14:23:14
问题 I'm trying to setup carrierwave and s3 with heroku. I'm following the carrierwave docs exactly: https://github.com/jnicklas/carrierwave I've setup a bucket named testbucket in AWS, then I installed fog and created a new initializer with this inside : CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', # required :aws_access_key_id => 'my_key_inside_here', # required :aws_secret_access_key => 'my_secret_access_key_here', # required :region => 'eu-west-1' # optional

How to update/rename a carrierwave uploaded file?

余生长醉 提交于 2020-01-01 00:21:05
问题 I cant figure out how to update/rename a file uploaded/managed with Carrierwave-mongoid in rails 3.2.6. I want to rename the file in the db as well as on the filesystem. Something like this maybe... def rename( id , new_name ) f = UploadedFile.find(id) if f.update_attributes({ f.file.original_filename: new_name }) # this is WRONG, what is right??? new_path = File.join( File.dirname( f.file.current_path ) , new_name )) FileUtils.mv( f.file.current_path , new_path ) end return f end Let me add

Mixed file types with CarrierWave

不想你离开。 提交于 2019-12-30 18:07:06
问题 I've a CarrierWave uploader that shall accept a variety of file types. Some are image types (e.g. jpg, png) others are not. I would like to create a medium version of the uploaded file with version :medium do process :resize_to_fit => [300, 300] end As this only works for image files, how can I distinguish between images and other types and omit the resizing for non-image files? At the moment CarrierWave tries to process the file regardless of it's type which leads to a MiniMagick processing

Mixed file types with CarrierWave

人走茶凉 提交于 2019-12-30 18:06:09
问题 I've a CarrierWave uploader that shall accept a variety of file types. Some are image types (e.g. jpg, png) others are not. I would like to create a medium version of the uploaded file with version :medium do process :resize_to_fit => [300, 300] end As this only works for image files, how can I distinguish between images and other types and omit the resizing for non-image files? At the moment CarrierWave tries to process the file regardless of it's type which leads to a MiniMagick processing

Stack level too deep when using carrierwave versions

不问归期 提交于 2019-12-30 04:06:23
问题 I'm trying to use a sidekiq worker, which more or less saves a image file to database (using carrierwave). There are few files to save, which are a keyframes extracted from a video file. That's what that worker is about. My image uploader has a few versions defined and looks as follows: class KeyframeUploader < CarrierWave::Uploader::Base # ... # Keyframe thumbnail sizes version :small do process resize_to_fill: [180, 180], if: :square? process resize_to_fill: [320, 180], if: :not_square? end

Upload file to S3 using CarrierWave without a model, is it possible?

大憨熊 提交于 2019-12-30 02:13:09
问题 CarrierWave has amazing documentation, until you need to do it without a model! I have my uploader and fog settings set up, and they all work fine when using the mounted uploader on a model, but now I want to do it without a model. I have this: uploader = CsvUploader.new something = uploader.store!(File.read(file_path)) uploader.retrieve_from_store!(self.file_name) When I call .store! the code runs immediately which is weird since it should take a few seconds to upload the file? Then after I

Uploading a remote file url from Rails Console with Carrierwave

℡╲_俬逩灬. 提交于 2019-12-30 00:13:08
问题 I just wanted to know how one would go about uploading a remote file url using Carrierwave in the Rails console. I tried the following without any luck. I presume it's not processing the Uploader? user = User.first user.remote_avatar_url = "http://www.image.com/file.jpg" user.save Many thanks 回答1: Take a look at the ' Uploading files from a remote location ' section on this page https://github.com/carrierwaveuploader/carrierwave CarrierWave should throw an error if the url of the location is

Override Rails Uploader to seed database

流过昼夜 提交于 2019-12-29 08:02:27
问题 I have a CarrierWave rails uploader. I want to seed the database with fake users so I'm trying to add the images in with the same seed file. The images are in a common storage, so if I can just get the avatar strings in the database they'll work. When it saves the users though the image's aren't sticking. # db/seeds.rb user1 = User.create :email => "test1@test.com", :password => "testing", :name => "Bob Dylan", :avatar => "v1357014344/bdylan.jpg" user1.save # IRB User.first => #<User id: 1,