s3_file_field 1.0.7 → 1.1.0
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/README.md +1 -1
- data/app/assets/javascripts/s3_file_field.js.coffee +18 -5
- data/lib/s3_file_field/config_aws.rb +1 -1
- data/lib/s3_file_field/s3_uploader.rb +4 -3
- data/lib/s3_file_field/version.rb +1 -1
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 771a79d8a1002b47f2dfcf1f24022292a5212590
         | 
| 4 | 
            +
              data.tar.gz: 4ebc755adee94a38cd0baac8dfb6657b9f637a2d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: d5e2da78facafbcd31cf7d597e5bed3cf335ae20efcfc2864b08a4035d2a6c4f18b60426bffe0d1437bb1354f29ce35256b8c8c8b48741e231e0979939807dc9
         | 
| 7 | 
            +
              data.tar.gz: cdd64aa49a7b27bb78974baab71c2796e41cb092ff3492e6298af99fe39d88902e3eccd3a03dbe0de19ea1a9240aef194acfada54d68bea25f7a78b635e2a764
         | 
    
        data/README.md
    CHANGED
    
    | @@ -7,7 +7,7 @@ jQuery File Upload extension for direct uploading to Amazon S3 using CORS | |
| 7 7 |  | 
| 8 8 | 
             
            Works as an extension of [jQuery File Upload](http://blueimp.github.io/jQuery-File-Upload/) JavaScript plugin and supports IE 7-10.
         | 
| 9 9 |  | 
| 10 | 
            -
             | 
| 10 | 
            +
            It supports multiple upload, and per-input configuration.
         | 
| 11 11 |  | 
| 12 12 | 
             
            ## Installation
         | 
| 13 13 |  | 
| @@ -63,7 +63,7 @@ jQuery.fn.S3FileField = (options) -> | |
| 63 63 | 
             
                  if add? then add(e, data) else data.submit()
         | 
| 64 64 |  | 
| 65 65 | 
             
                done: (e, data) ->
         | 
| 66 | 
            -
                  data.result = build_content_object | 
| 66 | 
            +
                  data.result = build_content_object(data.files[0], data.result)
         | 
| 67 67 | 
             
                  done(e, data) if done?
         | 
| 68 68 |  | 
| 69 69 | 
             
                fail: (e, data) ->
         | 
| @@ -85,11 +85,24 @@ jQuery.fn.S3FileField = (options) -> | |
| 85 85 |  | 
| 86 86 | 
             
              jQuery.extend settings, options
         | 
| 87 87 |  | 
| 88 | 
            -
               | 
| 89 | 
            -
                 | 
| 88 | 
            +
              to_s3_filename = (filename) ->
         | 
| 89 | 
            +
                trimmed = filename.replace(/^\s+|\s+$/g,'')
         | 
| 90 | 
            +
                strip_before_slash = trimmed.split('\\').slice(-1)[0]
         | 
| 91 | 
            +
                double_encode_quote = strip_before_slash.replace('"', '%22')
         | 
| 92 | 
            +
                encodeURIComponent(double_encode_quote)
         | 
| 93 | 
            +
             | 
| 94 | 
            +
              build_content_object = (file, result) ->
         | 
| 95 | 
            +
             | 
| 90 96 | 
             
                content = {}
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                 | 
| 97 | 
            +
             | 
| 98 | 
            +
                if result # Use the S3 response to set the URL to avoid character encodings bugs
         | 
| 99 | 
            +
                  content.url            = $(result).find("Location").text()
         | 
| 100 | 
            +
                  content.filepath       = $('<a />').attr('href', content.url)[0].pathname
         | 
| 101 | 
            +
                else # IE <= 9 returns null result so hack is necessary
         | 
| 102 | 
            +
                  domain = settings.url.replace(/\/+$/, '').replace(/^(https?:)?/, 'https:')
         | 
| 103 | 
            +
                  content.filepath   = finalFormData[file.unique_id]['key'].replace('/${filename}', '')
         | 
| 104 | 
            +
                  content.url        = domain + '/' + content.filepath + '/' + to_s3_filename(file.name)
         | 
| 105 | 
            +
             | 
| 93 106 | 
             
                content.filename   = file.name
         | 
| 94 107 | 
             
                content.filesize   = file.size if 'size' of file
         | 
| 95 108 | 
             
                content.filetype   = file.type if 'type' of file
         | 
| @@ -4,7 +4,7 @@ module S3FileField | |
| 4 4 | 
             
              class Config
         | 
| 5 5 | 
             
                include Singleton
         | 
| 6 6 |  | 
| 7 | 
            -
                ATTRIBUTES = [:access_key_id, :secret_access_key, :bucket, :prefix_to_clean, :region, :url]
         | 
| 7 | 
            +
                ATTRIBUTES = [:access_key_id, :secret_access_key, :bucket, :prefix_to_clean, :region, :url, :key_starts_with]
         | 
| 8 8 |  | 
| 9 9 | 
             
                attr_accessor *ATTRIBUTES
         | 
| 10 10 | 
             
              end
         | 
| @@ -12,7 +12,8 @@ module S3FileField | |
| 12 12 | 
             
                    expiration: 10.hours.from_now.utc.iso8601,
         | 
| 13 13 | 
             
                    max_file_size: 500.megabytes,
         | 
| 14 14 | 
             
                    conditions: [],
         | 
| 15 | 
            -
                    key_starts_with: 'uploads/'
         | 
| 15 | 
            +
                    key_starts_with: S3FileField.config.key_starts_with || 'uploads/',
         | 
| 16 | 
            +
                    region: S3FileField.config.region || 's3'
         | 
| 16 17 | 
             
                  }
         | 
| 17 18 |  | 
| 18 19 | 
             
                  @key = original_options[:key]
         | 
| @@ -59,7 +60,7 @@ module S3FileField | |
| 59 60 | 
             
                end
         | 
| 60 61 |  | 
| 61 62 | 
             
                def url
         | 
| 62 | 
            -
                  "//#{@options[:bucket]}. | 
| 63 | 
            +
                  "//#{@options[:bucket]}.#{@options[:region]}.amazonaws.com/"
         | 
| 63 64 | 
             
                end
         | 
| 64 65 |  | 
| 65 66 | 
             
                def policy
         | 
| @@ -84,7 +85,7 @@ module S3FileField | |
| 84 85 | 
             
                def signature
         | 
| 85 86 | 
             
                  Base64.encode64(
         | 
| 86 87 | 
             
                    OpenSSL::HMAC.digest(
         | 
| 87 | 
            -
                      OpenSSL::Digest | 
| 88 | 
            +
                      OpenSSL::Digest.new('sha1'),
         | 
| 88 89 | 
             
                      @options[:secret_access_key], policy
         | 
| 89 90 | 
             
                    )
         | 
| 90 91 | 
             
                  ).gsub("\n", '')
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: s3_file_field
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0 | 
| 4 | 
            +
              version: 1.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Adam Stankiewicz
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2014-03-10 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -130,15 +130,15 @@ executables: [] | |
| 130 130 | 
             
            extensions: []
         | 
| 131 131 | 
             
            extra_rdoc_files: []
         | 
| 132 132 | 
             
            files:
         | 
| 133 | 
            +
            - README.md
         | 
| 134 | 
            +
            - app/assets/javascripts/s3_file_field.js.coffee
         | 
| 135 | 
            +
            - lib/s3_file_field.rb
         | 
| 133 136 | 
             
            - lib/s3_file_field/config_aws.rb
         | 
| 134 137 | 
             
            - lib/s3_file_field/engine.rb
         | 
| 135 138 | 
             
            - lib/s3_file_field/form_helper.rb
         | 
| 136 139 | 
             
            - lib/s3_file_field/railtie.rb
         | 
| 137 140 | 
             
            - lib/s3_file_field/s3_uploader.rb
         | 
| 138 141 | 
             
            - lib/s3_file_field/version.rb
         | 
| 139 | 
            -
            - lib/s3_file_field.rb
         | 
| 140 | 
            -
            - app/assets/javascripts/s3_file_field.js.coffee
         | 
| 141 | 
            -
            - README.md
         | 
| 142 142 | 
             
            homepage: https://github.com/sheerun/s3_file_field
         | 
| 143 143 | 
             
            licenses:
         | 
| 144 144 | 
             
            - MIT
         | 
| @@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 159 159 | 
             
                  version: '0'
         | 
| 160 160 | 
             
            requirements: []
         | 
| 161 161 | 
             
            rubyforge_project: 
         | 
| 162 | 
            -
            rubygems_version: 2. | 
| 162 | 
            +
            rubygems_version: 2.2.1
         | 
| 163 163 | 
             
            signing_key: 
         | 
| 164 164 | 
             
            specification_version: 4
         | 
| 165 165 | 
             
            summary: jQuery File Upload extension for direct uploading to Amazon S3 using CORS
         |