carrierwave_direct 0.0.13 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.gitignore +1 -0
 - data/.travis.yml +15 -1
 - data/Changelog.md +130 -0
 - data/Gemfile +1 -1
 - data/README.md +82 -45
 - data/carrierwave_direct.gemspec +3 -4
 - data/gemfiles/3.2.gemfile +13 -0
 - data/gemfiles/4.0.gemfile +13 -0
 - data/gemfiles/4.1.gemfile +13 -0
 - data/lib/carrierwave_direct/form_builder.rb +48 -11
 - data/lib/carrierwave_direct/locale/nl.yml +9 -0
 - data/lib/carrierwave_direct/mount.rb +16 -4
 - data/lib/carrierwave_direct/orm/activerecord.rb +4 -4
 - data/lib/carrierwave_direct/test/capybara_helpers.rb +7 -5
 - data/lib/carrierwave_direct/uploader/configuration.rb +4 -2
 - data/lib/carrierwave_direct/uploader/content_type.rb +28 -0
 - data/lib/carrierwave_direct/uploader/direct_url.rb +15 -0
 - data/lib/carrierwave_direct/uploader.rb +79 -68
 - data/lib/carrierwave_direct/validations/active_model.rb +5 -4
 - data/lib/carrierwave_direct/version.rb +1 -1
 - data/lib/carrierwave_direct.rb +6 -8
 - data/spec/action_view_extensions/form_helper_spec.rb +4 -5
 - data/spec/data/sample_data.rb +41 -0
 - data/spec/form_builder_spec.rb +139 -6
 - data/spec/mount_spec.rb +13 -26
 - data/spec/orm/activerecord_spec.rb +69 -19
 - data/spec/spec_helper.rb +16 -2
 - data/spec/support/form_builder_helpers.rb +1 -0
 - data/spec/support/model_helpers.rb +7 -7
 - data/spec/support/view_helpers.rb +12 -2
 - data/spec/test/capybara_helpers_spec.rb +28 -26
 - data/spec/test/helpers_spec.rb +9 -11
 - data/spec/uploader/configuration_spec.rb +46 -0
 - data/spec/uploader/content_type_spec.rb +40 -0
 - data/spec/uploader/direct_url_spec.rb +26 -0
 - data/spec/uploader_spec.rb +145 -184
 - metadata +40 -39
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e4ad399ddf002036a40657b35ee0b50280a158b7
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 793b4c2f7228322befc4fec1b658b8f94322950c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 138bee67f0a6a9c78ebc483f2680dcd611dbb83ea5b2094f9e19d73e94015facaa782092d1200305bf966d974eca063fabb49383649f1864bed8726624e89551
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 160672ced1119afff6b7e6960e51fc4c4e1e382c9be00e8e58488b7aa24662fc5dfb4b26458c0ba3fd1881f6e52979f35558a72c9e4a5c6851dfebb2e09fee53
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -1,2 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            rvm:
         
     | 
| 
       2 
     | 
    
         
            -
             -  
     | 
| 
      
 2 
     | 
    
         
            +
             - 2.0.0
         
     | 
| 
      
 3 
     | 
    
         
            +
             - 2.1.0
         
     | 
| 
      
 4 
     | 
    
         
            +
             - 2.2.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            install:
         
     | 
| 
      
 6 
     | 
    
         
            +
              - 'travis_retry bundle install'
         
     | 
| 
      
 7 
     | 
    
         
            +
            script: 'bundle exec rspec spec'
         
     | 
| 
      
 8 
     | 
    
         
            +
            gemfile:
         
     | 
| 
      
 9 
     | 
    
         
            +
              - Gemfile
         
     | 
| 
      
 10 
     | 
    
         
            +
              - gemfiles/3.2.gemfile
         
     | 
| 
      
 11 
     | 
    
         
            +
              - gemfiles/4.0.gemfile
         
     | 
| 
      
 12 
     | 
    
         
            +
              - gemfiles/4.1.gemfile
         
     | 
| 
      
 13 
     | 
    
         
            +
            # Move to containerized travis, see http://docs.travis-ci.com/user/migrating-from-legacy
         
     | 
| 
      
 14 
     | 
    
         
            +
            sudo: false
         
     | 
| 
      
 15 
     | 
    
         
            +
            cache: bundler
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
    
        data/Changelog.md
    ADDED
    
    | 
         @@ -0,0 +1,130 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ### 0.0.17
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Misc:
         
     | 
| 
      
 4 
     | 
    
         
            +
              * Pin carrierwave to 0.11
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            ### 0.0.16
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Bug Fixes:
         
     | 
| 
      
 9 
     | 
    
         
            +
              * Allow uploader columns to be named `file` (Diego Plentz @plentz and Moisés Viloria @mois3x)
         
     | 
| 
      
 10 
     | 
    
         
            +
              * `["starts-with", "$utf8", ""]` is not needed as condition (Rocco Galluzzo @byterussian)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            Misc:
         
     | 
| 
      
 13 
     | 
    
         
            +
              * Dropped support for ruby 1.9, it has [reached its end of life](https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/) 
         
     | 
| 
      
 14 
     | 
    
         
            +
              * Add 2.2.0 support to travis. 
         
     | 
| 
      
 15 
     | 
    
         
            +
              * Compatible with Capybara 2.7
         
     | 
| 
      
 16 
     | 
    
         
            +
              * Replaced fog dependency with fog-aws; significantly reduces gem footprint
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ### 0.0.15
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.14...v0.0.15)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            Features:
         
     | 
| 
      
 23 
     | 
    
         
            +
              * Allow format validators to be used on update (Grey Baker @greysteil)
         
     | 
| 
      
 24 
     | 
    
         
            +
              * Add cache_dir to allowed paths (Grey Baker @greysteil)
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            Bug Fixes:
         
     | 
| 
      
 27 
     | 
    
         
            +
              * Use Carrierwave to generate URL's (Petrik de Heus @p8)
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            Misc:
         
     | 
| 
      
 30 
     | 
    
         
            +
              * README update (Samuel Reh @samuelreh)
         
     | 
| 
      
 31 
     | 
    
         
            +
              * Fix typo in README (Brandon Conway @brandoncc)
         
     | 
| 
      
 32 
     | 
    
         
            +
              * Fix specs for rspec 3 (Hanachin @hanachin)
         
     | 
| 
      
 33 
     | 
    
         
            +
              * Fix typo in nl.yml (Petrik de Heus @p8)
         
     | 
| 
      
 34 
     | 
    
         
            +
              * Add multiple rails versions support to travis (Petrik de Heus @p8)
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            ### 0.0.14
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.13...v0.0.14)
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            Features:
         
     | 
| 
      
 41 
     | 
    
         
            +
             * Add ability to set content type in upload form (John Kamenik @jkamenik)
         
     | 
| 
      
 42 
     | 
    
         
            +
             * Dutch language support (Ariejan de Vroom @ariejan)
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            Bug Fixes:
         
     | 
| 
      
 45 
     | 
    
         
            +
              * Escape characters in filenames (@geeky-sh)
         
     | 
| 
      
 46 
     | 
    
         
            +
              * Use OpenSSL::Digest instead of OpenSSL::Digest::Digest (@dwiedenbruch)
         
     | 
| 
      
 47 
     | 
    
         
            +
              * Fix signature race condition by caching policy (Louis Simoneau @lsimoneau)
         
     | 
| 
      
 48 
     | 
    
         
            +
              * Fix multi-encoding issue when saving escaped filenames (Vincent Franco @vinniefranco)
         
     | 
| 
      
 49 
     | 
    
         
            +
              * Use mounted-on column name for uniqueness validation (Stephan Schubert @jazen)
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            Misc:
         
     | 
| 
      
 52 
     | 
    
         
            +
              * Improve readme documentation for success action status support (Rafael Macedo @rafaelmacedo)
         
     | 
| 
      
 53 
     | 
    
         
            +
              * Increase robutness of view rpsec matchers (@sony-phoenix-dev)
         
     | 
| 
      
 54 
     | 
    
         
            +
              * Add ruby 2.1.0 support to travis (Luciano Sousa @lucianosousa)
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            ### 0.0.13
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.12...v0.0.13)
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            Features:
         
     | 
| 
      
 61 
     | 
    
         
            +
              * Add option to use success_action_status instead of success_action_redirect (Nick DeLuca @nddeluca)
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            Bug Fixes:
         
     | 
| 
      
 64 
     | 
    
         
            +
             * Remove intial slash when generating key from url in order to fix updates (Enrique García @kikito)
         
     | 
| 
      
 65 
     | 
    
         
            +
             * Fix key generation when #default_url is overriden (@dunghuynh)
         
     | 
| 
      
 66 
     | 
    
         
            +
             * Fix policy glitch that allows other files to be overwritten (@dunghuynh)
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            Misc:
         
     | 
| 
      
 69 
     | 
    
         
            +
             * Update resque url in readme (Ever Daniel Barreto @everdaniel)
         
     | 
| 
      
 70 
     | 
    
         
            +
             * update readme (Philip Arndt @parndt)
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            ### 0.0.12
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.11...v0.0.12)
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
            Features:
         
     | 
| 
      
 78 
     | 
    
         
            +
              * use uuidtools gem instead of uuid gem for uid generation (Filip Tepper @filiptepper)
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            Bug Fixes:
         
     | 
| 
      
 81 
     | 
    
         
            +
              * fix URI parsing issues with cetain filenames (Ricky Pai @rickypai)
         
     | 
| 
      
 82 
     | 
    
         
            +
              * prevent double slashes in urls generated from direct_fog_url (Colin Young @colinyoung)
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            Misc:
         
     | 
| 
      
 85 
     | 
    
         
            +
             * fix typo in readme (@hartator)
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            ### 0.0.11
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.10...v0.0.11)
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            ### 0.0.10
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.9...v0.0.10)
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            ### 0.0.9
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.8...v0.0.9)
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            ### 0.0.8
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.7...v0.0.8)
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            ### 0.0.7
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.6...v0.0.7)
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            ### 0.0.6
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.5...v0.0.6)
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            ### 0.0.5
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.4...v0.0.5)
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            ### 0.0.4
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.3...v0.0.4)
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            ### 0.0.3
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.2...v0.0.3)
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
            ### 0.0.2
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/v0.0.1...v0.0.2)
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            ### 0.0.1
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            [Full Changes](https://github.com/dwilkie/carrierwave_direct/compare/e68498587a4e4209d121512dbb0df529e15e9282...v0.0.1)
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -6,33 +6,6 @@ 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            [CarrierWaveDirect](https://github.com/dwilkie/carrierwave_direct) works on top of [CarrierWave](https://github.com/jnicklas/carrierwave) and provides a simple way to achieve this.
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            ## Project Maintainer(s) Wanted
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            Meh. [I just want to use it already.](https://github.com/dwilkie/carrierwave_direct#example-application)
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            ### Why can't you do it?
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            I'm no longer involved in building apps which require file uploads. Therefore I no longer feel that I can do a good job maintaining this project. I just want the community to take it where it needs to go.
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            ### What's in it for me?
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            * Everything
         
     | 
| 
       20 
     | 
    
         
            -
            * Job Applications
         
     | 
| 
       21 
     | 
    
         
            -
            * Not much
         
     | 
| 
       22 
     | 
    
         
            -
            * What you make of it
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            ### What do I need to do?
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            You can help by simply accepting pull requests and bumping versions. Or if you want to be more involved you could help resolve outstanding issues or develop new features.
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
            ### Who are you looking for?
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            Anybody who has previously contributed to CarrierWaveDirect (with tests) and/or who anybody who really wants to.
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
            ### How can I apply?
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            This is not a job application. I you want to maintain it, you've basically got the job. Just comment on this issue: https://github.com/dwilkie/carrierwave_direct/issues/83 and link to a contribution you've made on this gem, or some other gem.
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
9 
     | 
    
         
             
            ## Example Application
         
     | 
| 
       37 
10 
     | 
    
         | 
| 
       38 
11 
     | 
    
         
             
            For a concrete example on how to use [CarrierWaveDirect](https://github.com/dwilkie/carrierwave_direct) in a Rails application check out the [Example Application](https://github.com/dwilkie/carrierwave_direct_example).
         
     | 
| 
         @@ -183,7 +156,7 @@ end 
     | 
|
| 
       183 
156 
     | 
    
         
             
            After uploading to S3, You'll need to update the uploader object with the returned key in the controller action that corresponds to `new_user_url`:
         
     | 
| 
       184 
157 
     | 
    
         | 
| 
       185 
158 
     | 
    
         
             
            ```ruby
         
     | 
| 
       186 
     | 
    
         
            -
            @uploader.update_attribute : 
     | 
| 
      
 159 
     | 
    
         
            +
            @uploader.update_attribute :avatar_key, params[:key]
         
     | 
| 
       187 
160 
     | 
    
         
             
            ```
         
     | 
| 
       188 
161 
     | 
    
         | 
| 
       189 
162 
     | 
    
         
             
            You can also pass html options like this:
         
     | 
| 
         @@ -199,6 +172,9 @@ Note if `User` is not an ActiveRecord object e.g. 
     | 
|
| 
       199 
172 
     | 
    
         | 
| 
       200 
173 
     | 
    
         
             
            ```ruby
         
     | 
| 
       201 
174 
     | 
    
         
             
            class User
         
     | 
| 
      
 175 
     | 
    
         
            +
              extend CarrierWave::Mount
         
     | 
| 
      
 176 
     | 
    
         
            +
              extend CarrierWaveDirect::Mount
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
       202 
178 
     | 
    
         
             
              mount_uploader :avatar, AvatarUploader
         
     | 
| 
       203 
179 
     | 
    
         
             
            end
         
     | 
| 
       204 
180 
     | 
    
         
             
            ```
         
     | 
| 
         @@ -227,26 +203,45 @@ Once you've uploaded your file directly to the cloud you'll probably need a way 
     | 
|
| 
       227 
203 
     | 
    
         | 
| 
       228 
204 
     | 
    
         
             
            The default amazon content-type is "binary/octet-stream" and for many cases this will work just fine.  But if you are trying to stream video or audio you will need to set the mime type manually as Amazon will not calculate it for you.  All mime types are supported: [http://en.wikipedia.org/wiki/Internet_media_type](http://en.wikipedia.org/wiki/Internet_media_type).
         
     | 
| 
       229 
205 
     | 
    
         | 
| 
       230 
     | 
    
         
            -
            First, tell CarrierWaveDirect  
     | 
| 
      
 206 
     | 
    
         
            +
            First, tell CarrierWaveDirect what your default content type should be:
         
     | 
| 
       231 
207 
     | 
    
         | 
| 
       232 
208 
     | 
    
         
             
            ```ruby
         
     | 
| 
       233 
209 
     | 
    
         
             
            CarrierWave.configure do |config|
         
     | 
| 
       234 
210 
     | 
    
         
             
              # ... fog configuration and other options ...
         
     | 
| 
       235 
211 
     | 
    
         
             
              config.will_include_content_type = true
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
              config.default_content_type = 'video/mpeg'
         
     | 
| 
      
 214 
     | 
    
         
            +
              config.allowed_content_types = %w(video/mpeg video/mp4 video/ogg)
         
     | 
| 
      
 215 
     | 
    
         
            +
            end
         
     | 
| 
      
 216 
     | 
    
         
            +
            ```
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
            or
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 221 
     | 
    
         
            +
            class VideoUploader < CarrierWave::Uploader::Base
         
     | 
| 
      
 222 
     | 
    
         
            +
              include CarrierWaveDirect::Uploader
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
              def will_include_content_type
         
     | 
| 
      
 225 
     | 
    
         
            +
                true
         
     | 
| 
      
 226 
     | 
    
         
            +
              end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
              default_content_type  'video/mpeg'
         
     | 
| 
      
 229 
     | 
    
         
            +
              allowed_content_types %w(video/mpeg video/mp4 video/ogg)
         
     | 
| 
       236 
230 
     | 
    
         
             
            end
         
     | 
| 
       237 
231 
     | 
    
         
             
            ```
         
     | 
| 
       238 
232 
     | 
    
         | 
| 
       239 
     | 
    
         
            -
             
     | 
| 
      
 233 
     | 
    
         
            +
            *Note: If `will_include_content_type` is `true` and `default_content_type` is nil, the content type will default to 'binary/octet-stream'.*
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
            For the forms, no change is required to use the default_content_type.
         
     | 
| 
       240 
236 
     | 
    
         | 
| 
       241 
237 
     | 
    
         
             
            ```erb
         
     | 
| 
       242 
238 
     | 
    
         
             
            <%= direct_upload_form_for @uploader do |f| %>
         
     | 
| 
       243 
     | 
    
         
            -
              <%=  
     | 
| 
       244 
     | 
    
         
            -
              <%= f.file_field :avatar %>
         
     | 
| 
      
 239 
     | 
    
         
            +
              <%= f.file_field :avatar %> # Content-Type will automatically be set to the default
         
     | 
| 
       245 
240 
     | 
    
         
             
              <%= f.submit %>
         
     | 
| 
       246 
241 
     | 
    
         
             
            <% end %>
         
     | 
| 
       247 
242 
     | 
    
         
             
            ```
         
     | 
| 
       248 
243 
     | 
    
         | 
| 
       249 
     | 
    
         
            -
            You could use a select as well.
         
     | 
| 
      
 244 
     | 
    
         
            +
            You could use a manual select as well.
         
     | 
| 
       250 
245 
     | 
    
         | 
| 
       251 
246 
     | 
    
         
             
            ```erb
         
     | 
| 
       252 
247 
     | 
    
         
             
            <%= direct_upload_form_for @uploader do |f| %>
         
     | 
| 
         @@ -255,11 +250,24 @@ You could use a select as well. 
     | 
|
| 
       255 
250 
     | 
    
         
             
                ['Audio','audio/mpeg'],
         
     | 
| 
       256 
251 
     | 
    
         
             
                ['Image','image/jpeg']
         
     | 
| 
       257 
252 
     | 
    
         
             
              ], 'video/mpeg') %><br>
         
     | 
| 
       258 
     | 
    
         
            -
              <%= f.file_field :avatar %>
         
     | 
| 
      
 253 
     | 
    
         
            +
              <%= f.file_field :avatar, exclude_content_type: true %> # Must tell the file_field helper not to include content type
         
     | 
| 
      
 254 
     | 
    
         
            +
              <%= f.submit %>
         
     | 
| 
      
 255 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 256 
     | 
    
         
            +
            ```
         
     | 
| 
      
 257 
     | 
    
         
            +
             
     | 
| 
      
 258 
     | 
    
         
            +
            Or you can use the helper which shows all possible content types as a select, with the default content type selected.
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
            ```erb
         
     | 
| 
      
 261 
     | 
    
         
            +
            <%= direct_upload_form_for @uploader do |f| %>
         
     | 
| 
      
 262 
     | 
    
         
            +
              <%= f.content_type_label %><br>
         
     | 
| 
      
 263 
     | 
    
         
            +
              <%= f.content_type_select %><br><br>
         
     | 
| 
      
 264 
     | 
    
         
            +
             
     | 
| 
      
 265 
     | 
    
         
            +
              <%= f.file_field :avatar, exclude_content_type: true %><br> # Must tell the file_field helper not to include its own content type
         
     | 
| 
       259 
266 
     | 
    
         
             
              <%= f.submit %>
         
     | 
| 
       260 
267 
     | 
    
         
             
            <% end %>
         
     | 
| 
       261 
268 
     | 
    
         
             
            ```
         
     | 
| 
       262 
269 
     | 
    
         | 
| 
      
 270 
     | 
    
         
            +
             
     | 
| 
       263 
271 
     | 
    
         
             
            ## Processing and referencing files in a background process
         
     | 
| 
       264 
272 
     | 
    
         | 
| 
       265 
273 
     | 
    
         
             
            Processing and saving file uploads are typically long running tasks and should be done in a background process. CarrierWaveDirect gives you a few methods to help you do this with your favorite background processor such as [DelayedJob](https://github.com/collectiveidea/delayed_job) or [Resque](https://github.com/resque/resque).
         
     | 
| 
         @@ -332,7 +340,7 @@ class AvatarProcessor 
     | 
|
| 
       332 
340 
     | 
    
         
             
            end
         
     | 
| 
       333 
341 
     | 
    
         
             
            ```
         
     | 
| 
       334 
342 
     | 
    
         | 
| 
       335 
     | 
    
         
            -
            The method `self.remote_avatar_url=` from [CarrierWave](https://github.com/jnicklas/carrierwave) downloads the avatar from S3 and processes it. `save` then re-uploads the processed avatar to  
     | 
| 
      
 343 
     | 
    
         
            +
            The method `self.remote_avatar_url=` from [CarrierWave](https://github.com/jnicklas/carrierwave) downloads the avatar from S3 and processes it. `save` then re-uploads the processed avatar to S3
         
     | 
| 
       336 
344 
     | 
    
         | 
| 
       337 
345 
     | 
    
         
             
            ## Uploading from a remote location
         
     | 
| 
       338 
346 
     | 
    
         | 
| 
         @@ -407,14 +415,43 @@ CarrierWave.configure do |config| 
     | 
|
| 
       407 
415 
     | 
    
         
             
              config.validate_filename_format = false        # defaults to true
         
     | 
| 
       408 
416 
     | 
    
         
             
              config.validate_remote_net_url_format = false  # defaults to true
         
     | 
| 
       409 
417 
     | 
    
         | 
| 
       410 
     | 
    
         
            -
              config.min_file_size 
     | 
| 
       411 
     | 
    
         
            -
              config.max_file_size 
     | 
| 
       412 
     | 
    
         
            -
              config.upload_expiration 
     | 
| 
       413 
     | 
    
         
            -
              config.will_include_content_type =  
     | 
| 
       414 
     | 
    
         
            -
             
     | 
| 
       415 
     | 
    
         
            -
             
     | 
| 
      
 418 
     | 
    
         
            +
              config.min_file_size             = 5.kilobytes  # defaults to 1.byte
         
     | 
| 
      
 419 
     | 
    
         
            +
              config.max_file_size             = 10.megabytes # defaults to 5.megabytes
         
     | 
| 
      
 420 
     | 
    
         
            +
              config.upload_expiration         = 1.hour       # defaults to 10.hours
         
     | 
| 
      
 421 
     | 
    
         
            +
              config.will_include_content_type = 'video/mp4'  # defaults to false; if true, content-type will be set
         
     | 
| 
      
 422 
     | 
    
         
            +
                                                              # on s3, but you must include an input field named
         
     | 
| 
      
 423 
     | 
    
         
            +
                                                              # Content-Type on every direct upload form
         
     | 
| 
      
 424 
     | 
    
         
            +
             
     | 
| 
      
 425 
     | 
    
         
            +
              config.use_action_status = true                 # defaults to false; if true you must set in your uploader
         
     | 
| 
      
 426 
     | 
    
         
            +
                                                              # 'uploader.success_action_status = 201' and set
         
     | 
| 
      
 427 
     | 
    
         
            +
                                                              # 'f.file_field :avatar, use_action_status: true' to works
         
     | 
| 
      
 428 
     | 
    
         
            +
                                                              # properly
         
     | 
| 
       416 
429 
     | 
    
         
             
            end
         
     | 
| 
       417 
430 
     | 
    
         
             
            ```
         
     | 
| 
      
 431 
     | 
    
         
            +
             
     | 
| 
      
 432 
     | 
    
         
            +
            ## Bucket CORS configuration and usage with CloudFront
         
     | 
| 
      
 433 
     | 
    
         
            +
             
     | 
| 
      
 434 
     | 
    
         
            +
            If you are using a javascript uploader (e.g. Dropzone, jQuery Upload, Uploadify, etc.) you will need to add CORS configuration to your bucket, otherwise default bucket configuration will deny CORS requests. To do that open your bucket in Amazon console, click on its properties and add a CORS configuration similar to this
         
     | 
| 
      
 435 
     | 
    
         
            +
             
     | 
| 
      
 436 
     | 
    
         
            +
            ```xml
         
     | 
| 
      
 437 
     | 
    
         
            +
            <CORSConfiguration>
         
     | 
| 
      
 438 
     | 
    
         
            +
                <CORSRule>
         
     | 
| 
      
 439 
     | 
    
         
            +
                    <!--  Optionally change this with your domain, it should not be an issue since your bucket accepts only signed writes -->
         
     | 
| 
      
 440 
     | 
    
         
            +
                    <AllowedOrigin>*</AllowedOrigin>
         
     | 
| 
      
 441 
     | 
    
         
            +
                    <AllowedMethod>GET</AllowedMethod>
         
     | 
| 
      
 442 
     | 
    
         
            +
                    <AllowedMethod>POST</AllowedMethod>
         
     | 
| 
      
 443 
     | 
    
         
            +
                    <MaxAgeSeconds>3000</MaxAgeSeconds>
         
     | 
| 
      
 444 
     | 
    
         
            +
                    <AllowedHeader>Authorization</AllowedHeader>
         
     | 
| 
      
 445 
     | 
    
         
            +
                    <AllowedHeader>Content-Type</AllowedHeader>
         
     | 
| 
      
 446 
     | 
    
         
            +
                    <AllowedHeader>Origin</AllowedHeader>
         
     | 
| 
      
 447 
     | 
    
         
            +
                </CORSRule>
         
     | 
| 
      
 448 
     | 
    
         
            +
            </CORSConfiguration>
         
     | 
| 
      
 449 
     | 
    
         
            +
            ```
         
     | 
| 
      
 450 
     | 
    
         
            +
             
     | 
| 
      
 451 
     | 
    
         
            +
            When you use this gem in conjunction with CloudFront you'll need an additional step otherwise it won't work as expected. This is strictly necessary if you configured CarrierWave `asset_host` to use a CloudFront in front of your bucket because your forms will be posted to that url.
         
     | 
| 
      
 452 
     | 
    
         
            +
             
     | 
| 
      
 453 
     | 
    
         
            +
            To solve this issue you must enable POST requests in your CloudFront distribution settings. Here is a [step by step walkthrough](http://blog.celingest.com/en/2014/10/02/tutorial-using-cors-with-cloudfront-and-s3/) that explain this setup. It also explain CORS configuration.
         
     | 
| 
      
 454 
     | 
    
         
            +
             
     | 
| 
       418 
455 
     | 
    
         
             
            ## Testing with CarrierWaveDirect
         
     | 
| 
       419 
456 
     | 
    
         | 
| 
       420 
457 
     | 
    
         
             
            CarrierWaveDirect provides a couple of helpers to help with integration and unit testing. You don't want to contact the Internet during your tests as this is slow, expensive and unreliable. You should first put fog into mock mode by doing something like this.
         
     | 
| 
         @@ -517,8 +554,6 @@ en: 
     | 
|
| 
       517 
554 
     | 
    
         | 
| 
       518 
555 
     | 
    
         
             
            ## Caveats
         
     | 
| 
       519 
556 
     | 
    
         | 
| 
       520 
     | 
    
         
            -
            Don't name your string column `file`. It will result in a stack level too deep exception. See [this issue](https://github.com/dwilkie/carrierwave_direct/issues/10) for more info.
         
     | 
| 
       521 
     | 
    
         
            -
             
     | 
| 
       522 
557 
     | 
    
         
             
            If you're Rails app was newly generated *after* version 3.2.3 and your testing this in development you may run into an issue where an `ActiveModel::MassAssignmentSecurity::Error` is raised when being redirected from S3. You can fix this by setting `config.active_record.mass_assignment_sanitizer = :logger` in your `config/environments/development.rb` file.
         
     | 
| 
       523 
558 
     | 
    
         | 
| 
       524 
559 
     | 
    
         
             
            ## Contributing to CarrierWaveDirect
         
     | 
| 
         @@ -538,10 +573,10 @@ After you have fixed a bug or added a feature please also use the [CarrierWaveDi 
     | 
|
| 
       538 
573 
     | 
    
         | 
| 
       539 
574 
     | 
    
         
             
            ## Credits
         
     | 
| 
       540 
575 
     | 
    
         | 
| 
       541 
     | 
    
         
            -
            Thank you to everybody who has contributed to [CarrierWaveDirect](https://github.com/dwilkie/carrierwave_direct). A special thanks to [ 
     | 
| 
      
 576 
     | 
    
         
            +
            Thank you to everybody who has contributed to [CarrierWaveDirect](https://github.com/dwilkie/carrierwave_direct). A special thanks to [nddeluca (Nicholas DeLuca)](https://github.com/nddeluca) who does a great job maintaining this gem. If you'd like to help him out see [#83](https://github.com/dwilkie/carrierwave_direct/issues/83)
         
     | 
| 
       542 
577 
     | 
    
         | 
| 
       543 
578 
     | 
    
         
             
            ## Contributors
         
     | 
| 
       544 
     | 
    
         
            -
             
     | 
| 
      
 579 
     | 
    
         
            +
            * [geeky-sh](https://github.com/geeky-sh) - Allow filenames with '()+[]' characters
         
     | 
| 
       545 
580 
     | 
    
         
             
            * [cblunt (Chris Blunt)](https://github.com/cblunt) - Support for passing html options
         
     | 
| 
       546 
581 
     | 
    
         
             
            * [robyurkowski (Rob Yurkowski)](https://github.com/robyurkowski) - Fix deprecation warnings for Rails 3.2
         
     | 
| 
       547 
582 
     | 
    
         
             
            * [tylr (Tyler Love)](https://github.com/tylr) - Bug fix
         
     | 
| 
         @@ -559,4 +594,6 @@ Thank you to everybody who has contributed to [CarrierWaveDirect](https://github 
     | 
|
| 
       559 
594 
     | 
    
         
             
            * [rsniezynski](https://github.com/rsniezynski) - Add min file size configuration
         
     | 
| 
       560 
595 
     | 
    
         
             
            * [philipp-spiess (Philipp Spieß)](https://github.com/philipp-spiess) - Direct fog url bugfix
         
     | 
| 
       561 
596 
     | 
    
         
             
            * [colinyoung (Colin Young)](https://github.com/colinyoung) - Content-Type support
         
     | 
| 
      
 597 
     | 
    
         
            +
            * [jkamenik (John Kamenik)](https://github.com/jkamenik) - Content-Type support
         
     | 
| 
       562 
598 
     | 
    
         
             
            * [filiptepper (Filip Tepper)](https://github.com/filiptepper) - Autoload UUID on heroku
         
     | 
| 
      
 599 
     | 
    
         
            +
            * [mois3x (Moisés Viloria)](https://github.com/mois3x) and [plentz (Diego Plentz)](https://github.com/plentz) - Allow uploader columns to be named `file`
         
     | 
    
        data/carrierwave_direct.gemspec
    CHANGED
    
    | 
         @@ -10,13 +10,12 @@ Gem::Specification.new do |s| 
     | 
|
| 
       10 
10 
     | 
    
         
             
              s.homepage    = "https://github.com/dwilkie/carrierwave_direct"
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.summary     = %q{Upload direct to S3 using CarrierWave}
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.description = %q{Process your uploads in the background by uploading directly to S3}
         
     | 
| 
       13 
     | 
    
         
            -
              s.required_ruby_version = ">=  
     | 
| 
      
 13 
     | 
    
         
            +
              s.required_ruby_version = ">= 2.0.0"
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
              s.rubyforge_project = "carrierwave_direct"
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              s.add_dependency "carrierwave"
         
     | 
| 
       18 
     | 
    
         
            -
              s.add_dependency " 
     | 
| 
       19 
     | 
    
         
            -
              s.add_dependency "fog"
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.add_dependency "carrierwave", "~>0.11"
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.add_dependency "fog-aws"
         
     | 
| 
       20 
19 
     | 
    
         | 
| 
       21 
20 
     | 
    
         
             
              s.add_development_dependency "rspec"
         
     | 
| 
       22 
21 
     | 
    
         
             
              s.add_development_dependency "timecop"
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            source "https://rubygems.org"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            gem "carrierwave", "~>0.11"
         
     | 
| 
      
 4 
     | 
    
         
            +
            gem "fog-aws"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem "rspec", '3.0.0'
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem "timecop"
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem "rails", "~>3.2.12"
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem "capybara"
         
     | 
| 
      
 12 
     | 
    
         
            +
              # gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            source "https://rubygems.org"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            gem "carrierwave", "~>0.11"
         
     | 
| 
      
 4 
     | 
    
         
            +
            gem "fog-aws"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem "rspec", '3.0.0'
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem "timecop"
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem "rails", "~>4.0.0"
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem "capybara"
         
     | 
| 
      
 12 
     | 
    
         
            +
              # gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            source "https://rubygems.org"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            gem "carrierwave", "~>0.11"
         
     | 
| 
      
 4 
     | 
    
         
            +
            gem "fog-aws"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem "rspec", '3.0.0'
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem "timecop"
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem "rails", "~>4.1.0"
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem "capybara"
         
     | 
| 
      
 12 
     | 
    
         
            +
              # gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -3,21 +3,58 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            module CarrierWaveDirect
         
     | 
| 
       4 
4 
     | 
    
         
             
              class FormBuilder < ActionView::Helpers::FormBuilder
         
     | 
| 
       5 
5 
     | 
    
         
             
                def file_field(method, options = {})
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @object.policy(enforce_utf8: true)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       6 
8 
     | 
    
         
             
                  options.merge!(:name => "file")
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                  fields  
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                  fields <<  
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  fields = required_base_fields
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  fields << content_type_field(options)
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                  fields << success_action_field(options)
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  # The file field must be the last element in the form.
         
     | 
| 
      
 17 
     | 
    
         
            +
                  # Any element after this will be ignored by Amazon.
         
     | 
| 
      
 18 
     | 
    
         
            +
                  fields << super
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def content_type_label(content=nil)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  content ||= 'Content Type'
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @template.label_tag('Content-Type', content)
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def content_type_select(choices = [], selected = nil, options = {})
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @template.select_tag('Content-Type', content_choices_options(choices, selected), options)
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                private
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                def required_base_fields
         
     | 
| 
      
 33 
     | 
    
         
            +
                  hidden_field(:key,                     :name => "key") <<
         
     | 
| 
      
 34 
     | 
    
         
            +
                  hidden_field(:aws_access_key_id,       :name => "AWSAccessKeyId") <<
         
     | 
| 
      
 35 
     | 
    
         
            +
                  hidden_field(:acl,                     :name => "acl") <<
         
     | 
| 
      
 36 
     | 
    
         
            +
                  hidden_field(:policy,                  :name => "policy") <<
         
     | 
| 
      
 37 
     | 
    
         
            +
                  hidden_field(:signature,               :name => "signature")
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                def content_type_field(options)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  return ''.html_safe unless @object.will_include_content_type
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                  hidden_field(:content_type, :name => 'Content-Type') unless options[:exclude_content_type]
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                def success_action_field(options)
         
     | 
| 
      
 47 
     | 
    
         
            +
                  if @object.use_action_status
         
     | 
| 
      
 48 
     | 
    
         
            +
                    hidden_field(:success_action_status, :name => "success_action_status")
         
     | 
| 
       15 
49 
     | 
    
         
             
                  else
         
     | 
| 
       16 
     | 
    
         
            -
                     
     | 
| 
      
 50 
     | 
    
         
            +
                    hidden_field(:success_action_redirect, :name => "success_action_redirect")
         
     | 
| 
       17 
51 
     | 
    
         
             
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
       18 
53 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
                def content_choices_options(choices, selected = nil)
         
     | 
| 
      
 55 
     | 
    
         
            +
                  choices = @object.content_types if choices.blank?
         
     | 
| 
      
 56 
     | 
    
         
            +
                  selected ||= @object.content_type
         
     | 
| 
      
 57 
     | 
    
         
            +
                  @template.options_for_select(choices, selected)
         
     | 
| 
       20 
58 
     | 
    
         
             
                end
         
     | 
| 
       21 
59 
     | 
    
         
             
              end
         
     | 
| 
       22 
60 
     | 
    
         
             
            end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
         @@ -0,0 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            nl:
         
     | 
| 
      
 2 
     | 
    
         
            +
              errors:
         
     | 
| 
      
 3 
     | 
    
         
            +
                messages:
         
     | 
| 
      
 4 
     | 
    
         
            +
                  carrierwave_direct_filename_taken: bestandsnaam is reeds in gebruik
         
     | 
| 
      
 5 
     | 
    
         
            +
                  carrierwave_direct_upload_missing: geüpload bestand ontbreekt
         
     | 
| 
      
 6 
     | 
    
         
            +
                  carrierwave_direct_attachment_missing: bestand ontbreekt
         
     | 
| 
      
 7 
     | 
    
         
            +
                  carrierwave_direct_filename_invalid: "is ongeldig. "
         
     | 
| 
      
 8 
     | 
    
         
            +
                  carrierwave_direct_allowed_extensions: Toegestane bestandstypen zijn %{extensions}
         
     | 
| 
      
 9 
     | 
    
         
            +
                  carrierwave_direct_allowed_schemes: "Toegestane schema's zijn %{schemes}"
         
     | 
| 
         @@ -9,10 +9,12 @@ module CarrierWaveDirect 
     | 
|
| 
       9 
9 
     | 
    
         
             
                  # Don't go further unless the class included CarrierWaveDirect::Uploader
         
     | 
| 
       10 
10 
     | 
    
         
             
                  return unless uploader.ancestors.include?(CarrierWaveDirect::Uploader)
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                  uploader. 
     | 
| 
       13 
     | 
    
         
            -
                     
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
                  unless uploader.instance_methods.include?(column)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    uploader.class_eval <<-RUBY, __FILE__, __LINE__+1
         
     | 
| 
      
 14 
     | 
    
         
            +
                       def #{column}; self; end
         
     | 
| 
      
 15 
     | 
    
         
            +
                    RUBY
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
         
     | 
| 
       16 
18 
     | 
    
         
             
                  self.instance_eval <<-RUBY, __FILE__, __LINE__+1
         
     | 
| 
       17 
19 
     | 
    
         
             
                    attr_accessor :remote_#{column}_net_url
         
     | 
| 
       18 
20 
     | 
    
         
             
                  RUBY
         
     | 
| 
         @@ -22,10 +24,20 @@ module CarrierWaveDirect 
     | 
|
| 
       22 
24 
     | 
    
         
             
                  mod.class_eval <<-RUBY, __FILE__, __LINE__+1
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
       24 
26 
     | 
    
         
             
                    def key
         
     | 
| 
      
 27 
     | 
    
         
            +
                      warn "key method is deprecated, please use column_key method instead."
         
     | 
| 
       25 
28 
     | 
    
         
             
                      send(:#{column}).key
         
     | 
| 
       26 
29 
     | 
    
         
             
                    end
         
     | 
| 
       27 
30 
     | 
    
         | 
| 
       28 
31 
     | 
    
         
             
                    def key=(k)
         
     | 
| 
      
 32 
     | 
    
         
            +
                      warn "key= method is deprecated, please use column_key= method instead."
         
     | 
| 
      
 33 
     | 
    
         
            +
                      send(:#{column}).key = k
         
     | 
| 
      
 34 
     | 
    
         
            +
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    def #{column}_key
         
     | 
| 
      
 37 
     | 
    
         
            +
                      send(:#{column}).key
         
     | 
| 
      
 38 
     | 
    
         
            +
                    end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                    def #{column}_key=(k)
         
     | 
| 
       29 
41 
     | 
    
         
             
                      send(:#{column}).key = k
         
     | 
| 
       30 
42 
     | 
    
         
             
                    end
         
     | 
| 
       31 
43 
     | 
    
         | 
| 
         @@ -25,14 +25,14 @@ module CarrierWaveDirect 
     | 
|
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                  validates_is_attached column if uploader_option(column.to_sym, :validate_is_attached)
         
     | 
| 
       27 
27 
     | 
    
         
             
                  validates_is_uploaded column if uploader_option(column.to_sym, :validate_is_uploaded)
         
     | 
| 
       28 
     | 
    
         
            -
                  validates_filename_uniqueness_of 
     | 
| 
       29 
     | 
    
         
            -
                  validates_filename_format_of 
     | 
| 
       30 
     | 
    
         
            -
                  validates_remote_net_url_format_of 
     | 
| 
      
 28 
     | 
    
         
            +
                  validates_filename_uniqueness_of(column, on: :create) if uploader_option(column.to_sym, :validate_unique_filename)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  validates_filename_format_of(column, on: :create) if uploader_option(column.to_sym, :validate_filename_format)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  validates_remote_net_url_format_of(column, on: :create) if uploader_option(column.to_sym, :validate_remote_net_url_format)
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
32 
     | 
    
         
             
                  self.instance_eval <<-RUBY, __FILE__, __LINE__+1
         
     | 
| 
       33 
33 
     | 
    
         
             
                    attr_accessor   :skip_is_attached_validations
         
     | 
| 
       34 
34 
     | 
    
         
             
                    unless defined?(ActiveModel::ForbiddenAttributesProtection) && ancestors.include?(ActiveModel::ForbiddenAttributesProtection)
         
     | 
| 
       35 
     | 
    
         
            -
                      attr_accessible  
     | 
| 
      
 35 
     | 
    
         
            +
                      attr_accessible :#{column}_key, :remote_#{column}_net_url
         
     | 
| 
       36 
36 
     | 
    
         
             
                    end
         
     | 
| 
       37 
37 
     | 
    
         
             
                  RUBY
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
         @@ -11,11 +11,11 @@ module CarrierWaveDirect 
     | 
|
| 
       11 
11 
     | 
    
         
             
                  end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                  def find_key
         
     | 
| 
       14 
     | 
    
         
            -
                    key = page.find("input[ 
     | 
| 
      
 14 
     | 
    
         
            +
                    key = page.find("input[name='key']", visible: false).value
         
     | 
| 
       15 
15 
     | 
    
         
             
                  end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                  def find_upload_path
         
     | 
| 
       18 
     | 
    
         
            -
                    page.find("input[ 
     | 
| 
      
 18 
     | 
    
         
            +
                    page.find("input[name='file']", visible: false).value
         
     | 
| 
       19 
19 
     | 
    
         
             
                  end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
                  def upload_directly(uploader, button_locator, options = {})
         
     | 
| 
         @@ -26,19 +26,21 @@ module CarrierWaveDirect 
     | 
|
| 
       26 
26 
     | 
    
         
             
                      # simulate a successful upload
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                      # form's success action redirect url
         
     | 
| 
       29 
     | 
    
         
            -
                      redirect_url = URI.parse(page.find("input[ 
     | 
| 
      
 29 
     | 
    
         
            +
                      redirect_url = URI.parse(page.find("input[name='success_action_redirect']", visible: false).value)
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
                      unless options[:redirect_key]
         
     | 
| 
       32 
32 
     | 
    
         
             
                        sample_key_args = [{:base => find_key, :filename => File.basename(find_upload_path)}]
         
     | 
| 
       33 
33 
     | 
    
         
             
                        sample_key_args.unshift(uploader) if method(:sample_key).arity == -2
         
     | 
| 
       34 
34 
     | 
    
         
             
                        options[:redirect_key] = sample_key(*sample_key_args)
         
     | 
| 
       35 
35 
     | 
    
         
             
                      end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
                      
         
     | 
| 
      
 37 
     | 
    
         
            +
                      redirect_url_params = Rack::Utils.parse_nested_query(redirect_url.query)
         
     | 
| 
      
 38 
     | 
    
         
            +
                      
         
     | 
| 
       37 
39 
     | 
    
         
             
                      redirect_url.query = Rack::Utils.build_nested_query({
         
     | 
| 
       38 
40 
     | 
    
         
             
                        :bucket => uploader.fog_directory,
         
     | 
| 
       39 
41 
     | 
    
         
             
                        :key => options[:redirect_key],
         
     | 
| 
       40 
42 
     | 
    
         
             
                        :etag => "\"d41d8cd98f00b204e9800998ecf8427\""
         
     | 
| 
       41 
     | 
    
         
            -
                      })
         
     | 
| 
      
 43 
     | 
    
         
            +
                      }.merge(redirect_url_params))
         
     | 
| 
       42 
44 
     | 
    
         | 
| 
       43 
45 
     | 
    
         
             
                      # click the button
         
     | 
| 
       44 
46 
     | 
    
         
             
                      click_button button_locator
         
     | 
| 
         @@ -1,7 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module CarrierWaveDirect
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
4 
     | 
    
         
             
              module Uploader
         
     | 
| 
       6 
5 
     | 
    
         
             
                module Configuration
         
     | 
| 
       7 
6 
     | 
    
         
             
                  extend ActiveSupport::Concern
         
     | 
| 
         @@ -16,7 +15,10 @@ module CarrierWaveDirect 
     | 
|
| 
       16 
15 
     | 
    
         
             
                    add_config :min_file_size
         
     | 
| 
       17 
16 
     | 
    
         
             
                    add_config :max_file_size
         
     | 
| 
       18 
17 
     | 
    
         
             
                    add_config :upload_expiration
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    add_config :will_include_content_type #alias for default_content_type
         
     | 
| 
      
 20 
     | 
    
         
            +
                    add_config :default_content_type
         
     | 
| 
      
 21 
     | 
    
         
            +
                    add_config :allowed_content_types
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
                    add_config :use_action_status
         
     | 
| 
       22 
24 
     | 
    
         |