carrierwave

https://github.com/carrierwaveuploader/carrierwave

Ruby

Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks

CarrierWave::Uploader::Versions#url

When given a version name as a parameter, will return the url for that version
This also works with nested versions.
When given a query hash as a parameter, will return the url with signature that contains query params
Query hash only works with AWS (S3 storage).

=== Example

    my_uploader.url                 # => /path/to/my/uploader.gif
    my_uploader.url(:thumb)         # => /path/to/my/thumb_uploader.gif
    my_uploader.url(:thumb, :small) # => /path/to/my/thumb_small_uploader.gif
    my_uploader.url(:query => {"response-content-disposition" => "attachment"})
    my_uploader.url(:version, :sub_version, :query => {"response-content-disposition" => "attachment"})

=== Parameters

[*args (Symbol)] any number of versions
OR/AND
[Hash] query params

=== Returns

[String] the location where this file is accessible via a url

Source | Google | Stack overflow

Edit

git clone [email protected]:carrierwaveuploader/carrierwave.git

cd carrierwave

open lib/carrierwave/uploader/versions.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-CarrierWave--Uploader--Versions-url-for-pr


# Commit to git

git add lib/carrierwave/uploader/versions.rbgit commit -m "better docs for CarrierWave::Uploader::Versions#url"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-CarrierWave--Uploader--Versions-url-for-pr

hub pull-request


# Celebrate!