Giter VIP home page Giter VIP logo

carrierwave's People

Contributors

alexcrichton avatar amatsuda avatar atz avatar avgerin0s avatar bensie avatar bquorning avatar brianhawley avatar clickworkorange avatar durran avatar geemus avatar jnicklas avatar minter avatar mshibuya avatar nashbridges avatar pk avatar plribeiro3000 avatar qhoxie avatar rajyan avatar rmm5t avatar samlown avatar scottwb avatar snoopie avatar st0012 avatar stanhu avatar taavo avatar thiagofm avatar thomasfedb avatar trevorturk avatar wonda-tea-coffee avatar ydah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carrierwave's Issues

s3_headers not working

I don't think the s3_headers thing is working correctly. Either that, or I'm doing something wrong ;)

In an initializer, I have:

CarrierWave.configure do |config|
config.s3_access_key_id = CONFIG['s3_access_id']
config.s3_secret_access_key = CONFIG['s3_secret_key']
config.s3_bucket = CONFIG['s3_bucket_name']
config.s3_access = :public_read
config.s3_headers = {'Cache-Control' => 'max-age=315576000', 'Expires' => 99.years.from_now.httpdate}
end

When I boot the app, I get:

undefined method `s3_headers=' for CarrierWave::Uploader::Base:Class

Using Model before save callbacks is potentially dangerous

Because the model is not saved in before hooks one can't use model.id or other properties which are filled after model is saved. So for example using Sequel one can't use the model.id in the Uploader#store_dir because method is called before the save and the model.id is unknown.

Is it as easy as using after save hooks or it gets more complicated?

random filename problem

I had a little trouble getting random filenames to work by defining the "filename" method. I ended up finding a workaround, but I thought it might be worth mentioning in any case:

http://pastie.org/804613

I dug around in the gem, but I couldn't seem to figure out if/why the filename was being set twice in my app.

Add logging for what's going

There needs to be a way how to show what's going on during the image processing or model saving. Now it's king of a black box.

Set logger according to the framework and log as info level could be a way to go.

Bundler needs gemspec file

Hi,

I would like to use CarrierWave with Rails 3 but Bundler needs the gemspec file for the following line :

gem "carrierwave", :git => "git://github.com/jnicklas/carrierwave.git"

Mongo connection blowing up in 0.4.5

hey, I have a site using CW with GridFS, ruby driver 0.18.3. It worked fine with 0.4.4 but when I updated to 0.4.5 it blows up with this:

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
from /Library/Ruby/Gems/1.8/gems/mongo-0.18.3/lib/../lib/mongo/connection.rb:303:in connect_to_master' from /Library/Ruby/Gems/1.8/gems/mongo-0.18.3/lib/../lib/mongo/connection.rb:121:ininitialize'
from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/storage/grid_fs.rb:89:in new' from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/storage/grid_fs.rb:89:indatabase'
from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/storage/grid_fs.rb:77:in retrieve!' from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/uploader/store.rb:73:inretrieve_from_store!'
from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/uploader/callbacks.rb:13:in with_callbacks' from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/uploader/store.rb:72:inretrieve_from_store!'
from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/mount.rb:287:in uploader' from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/mount.rb:168:infront'
from /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/mount.rb:156:in `front'
from (irb):2

I see that an optional port variable can be passed in but looking at the code I don't see where the problem is. Anyone else had this issue?

UPDATE: I found the cause of the problem. In line 53 of http://github.com/jnicklas/carrierwave/blob/master/lib/carrierwave/uploader/configuration.rb, change config.grid_fs_host to config.grid_fs_port ; )

filename override not quite working

I'm using

after_initialize { |track| track.uuid = random_generator }
mount_uploader :file, FileUploader

in my model, and

def filename
"#{model.uuid}.xxx"
end

in FileUploader, the :audio column will always store '.mp3' even if the uuid is there.

uploader.rb? Where is it?

Using carrierwave master for some rails 3 goodness... Tried to run the generator (which I understand might not be working yet) and it stated "Could not find "uploader.rb" in source paths.". No biggie. I figure I'll just copy the contents of uploader.rb manually to app/uploaders... but there is no uploader.rb in the repo...

Guidance?

errors using 0.4.1

Duh, I read some commit history and crop_resized has been removed. That's what was causing it. Sorry for the noise!

GridFS storage option doesn't allow me to use a non-default port

I was able to add a custom config var by adding the following to my initializer:

CarrierWave::Uploader::Base.add_config :grid_fs_port

But seeing as having a custom port to a Mongo server is probably a pretty common thing, it might make sense to add this into the default config vars.

Provide default s3_headers value

The s3_headers option was added without a default, breaking any app using carrier_wave and S3 it seems. It probably should default to {} to avoid issues.

S3 CNAMES generate URLs with extra '/'

The problem is on line 99 in lib/storage/s3.rb:

["http://", @uploader.s3_bucket, @path].compact.join('/')

Joining the bucket name and "http://" with a '/' results in something like "http:///my-bucket.example.com". Every browser I've tried seems to accept this, but it should just be two slashes.

ImageMagick support

One of the biggest selling points of Paperclip (and the reason I wont switch to carrierwave) is because of the direct integration with ImageMagick. If CW was able to integrate, then really there would be no reason to use any other file upload plugin/gem. How hard would it be to pull off?

"Rails 3" nastyness for inheritable class attributes causes problems with other modules (eg. couchrest)

Hi. Took me a while to discover that after adding carrierwave my CouchDB models stopped working when some of the class methods couldn't be found. Perhaps there are other modules with the same issue.

I've no doubt there is probably some strangeness in CouchRest that doesn't help, but does carrierwave really need to depend on such hacks when an include would suffice? The top of carrierwave/core_ext/inheritable_attributes.rb says it all:

# Retain for backward compatibility.  Methods are now included in Class.

Otherwise, the plugin looks cool, I like the approach, and if possible I'd like to add CouchRest::ExtendedDocument support at some point.

Cheers, sam

docs: heroku read-only filesystem

When trying to use carrierwave on heroku, I received this error:

Errno::EROFS: Read-only file system - /disk1/home/slugs/76400_2681065_f91e/mnt/public/uploads - Heroku has a read-only filesystem. See http://docs.heroku.com/constraints#read-only-filesystem

I was able to work around the issue by reading about it here:

http://codingfrontier.com/carrierwave-on-heroku

The bare minimum needed to work around the issue is to add the following to your Uploader class:

def cache_dir
"#{RAILS_ROOT}/tmp/uploads"
end

Please feel free to close this issue. I just want to make sure it's easy to locate for other people that might have the same problem. It may also be worth mentioning in the docs.

My apologies for being so bothersome with all these issues ;) I'm finding carrierwave to be a real pleasure to work with, and my hope in documenting these small gotchas is that other people will be able to more easily use carrierwave in the future. Thank you!

Load error: Rails expects "Carrierwave" not "CarrierWave"

When I add

gem.config 'carrierwave'

to my environment.rb I get the following error:

/Library/Ruby/Gems/1.8/gems/carrierwave-0.4.3/lib/carrierwave.rb:10: warning: already initialized constant VERSION
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:426:in `load_missing_constant': Expected /Library/Ruby/Gems/1.8/gems/carrierwave-0.4.3/lib/carrierwave.rb to define Carrierwave (LoadError)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing_not_from_s3_library'
  from /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
  from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
  from /Users/theo/…/config/initializers/carrierwave.rb:1

(path to the app elided for my privacy)

It seems like Rails expects carrierwave.rb to define Carrierwave (lowercase w), but it defines CarrierWave (uppercase w). Adding

config.gem 'carrierwave', :lib => 'CarrierWave'

doesn't solve the problem.

I'm using Rails 2.3.5.

Problem with output format

Hello,

I want to save all uploaded pictures to png format so I use the following code in my picture_uploader.rb

process :convert => :png

If I do that uploaded file is save as foo.jpg and is in jpg format. So I've overloded the filename methods

def filename
  "#{model.id}.png" if original_filename
end

And with that the file is save as #####.png but is still in jpg format.

I don't think the problem is with ImageMagick or RMagick because this test work just fine

process :to_format => :png

def to_format(format)
  manipulate! do |img|
    img.format = format.to_s.upcase
    img = img.sepiatone
    img.write('foobar.png')
    img
  end
end

The picture is saved as foobar.png and its format is really png.

I've read a lot of your code but I can't figured out why this doesn't work but I've found a strange (to my eyes :-) piece of code in carrierwave/lib/carrierwave/processing/rmagick.rb

module ClassMethods
  def convert(format)
    process :resize_to_limit => format
  end

Should it be something like that no ?

def convert(format)
    process :convert => format
  end

Carrierwave doesn't support EU S3-buckets

EU buckets can't be accessed using the bucket name in the path, they can only be accessed through virtual domains.
Works: http://eu-bucket-name.s3.amazonaws.com/keyname
Doesn't work: http://s3.amazonaws.com/eu-bucket-name/keyname

Carrierwave always uses the path url.

The problem is even worse as AWS-S3 doesn't support EU-buckets either. There are a patch that can be used at http://github.com/vladr/aws-s3/commit/a13504ba581496eab253583f38d26aa475949b53

rightaws-s3 do support EU Buckets.

To do in carrierwave:

  • Storage::S3#url must be updated.
  • establish_connection must get a server attribute with the host name including the bucket name subdomain with the current patch of AWS-S3.

Serializing to JSON

Serializing to json, when using default to_json causes SystemStackError (stack level too deep). I believe that is because Uploader object holds reference to parent item.

Best place for CarrierWave.configure

I'm sure I've missed something, but no matter where I put the CarrierWave.configure section for providing the S3 connection details it complains that it cannot find the configure method for the Module:

.../config/initializers/carrierwave_s3.rb:1:NoMethodError: undefined method `configure' for CarrierWave:Module

I'd also like to put it in the environment initializers so that I can use different settings depending on the environment, but it can't find the configure method then either.

Is there something I'm missing?

Cheers, sam

s3_headers configuration issue

I tried to configure s3_headers using the CarrierWave.configure block method in an initializer and got the following error message:

undefined method `s3_headers=' for CarrierWave::Uploader::Base:Class

Overriding the s3_headers method in my uploader works fine.

MongoMapper ORM adaptor does not use MongoDB's GridFS

This is more of a feature request, but it would be cool if storing files to MongoDB's built-in filesystem was an option. The simplicity of storing all the assets of a site - files and data - in one place is one of MongoDB's best features.

S3 EU-Buckets

Hi,

from this commit http://github.com/jnicklas/carrierwave/commit/cc12d370c08d8e421769bb4ce284762441bf1145#L0L98

my s3 european buckets did't work.

I changed my uploader with this config:

    config.s3_bucket = 'assets-web.s3.amazonaws.com'
    config.s3_cnamed = true

I can see perfectly my assets but I can't upload them.

ERROR - [07/Mar/2010 18:54:53] "RightAws::AwsError - NoSuchBucket: The specified bucket does not exist:
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/awsbase/right_awsbase.rb:359:in `request_info_impl'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/s3/right_s3_interface.rb:169:in `request_info'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/right_aws-1.10.0/lib/s3/right_s3_interface.rb:403:in `put'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/storage/right_s3.rb:111:in `store'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/storage/right_s3.rb:146:in `store!'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/uploader/store.rb:58:in `store!'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/uploader/callbacks.rb:13:in `with_callbacks'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/uploader/store.rb:57:in `store!'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/mount.rb:325:in `store!'
/opt/ruby-enterprise/lib/ruby/gems/1.8/gems/carrierwave-0.4.5/lib/carrierwave/mount.rb:216:in `store_file!'

Documentation Issue

Hi, in the README you write:

It might be a good idea to show the user that a file has been uploaded, in the case of images, a small thumbnail would be a good indicator:

<% form_for @user do |f| %>
  <p>
    <label>My Avatar</label>
    <%= image_tag(@user.avatar.url) if @user.avatar %>
    <%= f.file_field :avatar %>
    <%= f.hidden_field :avatar_cache %>
  </p>
<% end %>

It should be:

<%= image_tag(@user.avatar.url) if @user.avatar.url %>

MongoMapper - can't modify frozen object on destroy

Jonas, great upload gem. I really like it - was super easy to get started with. Thank you.

I am getting one error related to using it with mongomapper, but I realize you just added this support.

The error is 'Type error: can't modify frozen object' when doing User.destroy_all or User.first.destroy, etc. The error is only on destroy and the user actually gets destroyed, but tests fail because of the ugly error.

Following is the stacktrace with the rspec test I'm running. I had the same issues when running in merb -i -e test|development

http://gist.github.com/177890

I do not get the same error if I delete by doing: User.delete(@u.id) or User.delete_all

Possibly, it's related to MongoMapper's destroy method in lib/document.rb lines 302-308?:
def destroy
return false if frozen?

    criteria = FinderOptions.to_mongo_criteria(:_id => id)
    collection.remove(criteria) unless new?
    freeze
  end

to_json requires 'options' hash

Can reproduce error by:

class Product < ActiveRecord::Base
mount_uploader :image, ProductImageUploader
end
Product.all.to_json

Fix:
In uploader/url.rb

def to_json(options)
{ 'url' => url }.to_json(options)
end

I'd submit a patch, but I don't know how. Thanks!

right_aws: CNAME .url method versus config.s3_bucket

When writing to S3 you need config.s3_bucket to not have the full domain name i.e. just the bucket name.

When reading from S3 you need config.s3_bucket to have the full cname domain. This breaks writing (no such bucket).

Detach an image

My Rails application requires that a user be able to "detach" an image that has been uploaded. How is this achieved with CarrierWave? I would expect @post.image = nil; @post.save to do this, but the @post.image persists as an ImageUploader instance with a file attribute pointing to a file on S3.

gem build fails w/ non-existent files

Manifest.txt contains references to:
lib/carrierwave/uploader/default_path.rb
spec/uploader/default_path_spec.rb

.. which don't exist.

update: didn't see the "rake manifest" tool. I can't run it though, complains about a missing .hoerc file - needs to be added? Anyway added the files manually + sent pull request; you may just want to run the rake tool, though...

How I can?

Hi,

first thanks for this beautiful gem !

One question, but If I have a model and this model has_many mount_uploaders ?

Generally I have 1/2/3 attachment for model, but in much cases my model can have X (non predicted) attachments.

How we can do that?

docs: gotcha with machinst

While moving from paperclip to carrierwave, I ran into a little gotcha with machinist.

With paperclip, you can simply use a sham file name in a blueprint. With carrierwave, it seems to require having an actual file.

For example:

http://pastie.org/804376

You can feel free to close this issue, but I wanted something available for our friendly google searchers ;)

If you think it's appropriate, it might be worth mentioning in the docs somewhere.

CarrierWave.clean_cached_files! doesn't work if your cache_dir is not the default

CarrierWave.clean_cached_files! references CarrierWave.root, which is not the correct directory to be deleting files from if you modify your cache_dir inside of an Uploader (i.e. to circumvent Heroku's read only file system). Perhaps we could have a config setting that allows us to define multiple paths to check for tmp files when running CarrierWave.clean_cached_files!, with a default of CarrierWave.root.

And we might as well also create a default rake task while we're at it.

public/uploads

A minor thing, but I'm wondering why carrierwave us using "public/uploads" as the tmp dir. I've had to add the following to my .gitignore:

public/uploads/*/

...but is there a reason that you might not just use the pre-existing tmp/ directory? If not, perhaps this is worth mentioning in the readme?

feature: allow blank store_dir for s3 and right_s3

The way things work currently, I don't think you can specify an empty store_dir for s3. If you do, you'll get an extra "/" in the url. For example:

http://s3.amazonaws.com/example//ddc2edb.mp3

Note the double "/" after "example".

I think this could be fixed in the storage/s3.rb#url method, but I'm not sure...

[edit]

FWIW - I'm able to work around this issue like so for now:

http://pastie.org/803548

I'm trying to figure out how to make this work in all cases, though.

[edit]

On a related note, I noticed that there are two definitions of the url method:

http://pastie.org/805031

I'm wondering if there's a reason they are different and/or might these two methods be shared somehow?

[edit]

In my limited testing, it seems that right_aws doesn't play well with trying to upload files when given an empty store_dir. I discuss a bit further in this issue:

http://github.com/jnicklas/carrierwave/issues/issue/8#issue/8/comment/123665

...but the takeaway is that aws/s3 works as expected if given an empty store_dir, but right_aws does not. I'm not sure if this is a problem with carrierwave or not, though.

[edit]

This comment:

http://github.com/jnicklas/carrierwave/issues/closed/#issue/8/comment/123710

...was correct. Using "nil" instead of a blank string works for right_aws, but it requires overriding the store_path method like so:

http://pastie.org/805155

GridFS contentType not storing

It appears that no matter what contentType of file that I upload when I inspect the db from mongo shell it is always text/plain

Rails 3 and private method write_attribute

carrierwave throws an error in Rails 3 edge because write_attribute is now a private method.

It can be changed to:

alias_method :read_uploader, :[]
alias_method :write_uploader, :[]=

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.