lazy_blob_storage 2.0.0.pre.beta.6 → 2.0.0.pre.beta.8
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 +12 -3
- data/app/models/concerns/lazy_attachable.rb +1 -1
- data/db/migrate/20230309225433_create_lazy_variants.rb +13 -3
- data/lib/lazy_blob_storage/version.rb +1 -1
- data/lib/lazy_blob_storage.rb +9 -0
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0bd41b24bf9723782e729a80453c891b7997a1a254ec3020c966420fcf971fd5
         | 
| 4 | 
            +
              data.tar.gz: 5936757ccfb7262de3caa1d3e1b9b5910e97561286d3895769d3b9cb9f5716dc
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 4d02e19f73babc258462411c376b78368b46e742dc0ba1f5b944f27d3d585bd21b309a6ab825b7ab75ab79e36620abbc39f62b5ffedbf957d56601962eb5c8e1
         | 
| 7 | 
            +
              data.tar.gz: 2d6618d774f70847c975cc4eb1d58fbc75bf893d3a843928032a4672facd8de3b5f20a90c050ff0426763b4650b6c6606428fe0ea9a08786282ff7843544475f
         | 
    
        data/README.md
    CHANGED
    
    | @@ -8,15 +8,24 @@ digest to prevent duplicate blob uploads. | |
| 8 8 | 
             
            Nothing fancy. Just stores files and allows public access using the
         | 
| 9 9 | 
             
            digest as a key. Respects HTTP Cache headers.
         | 
| 10 10 |  | 
| 11 | 
            -
            You probably want to put a CDN/Cache/RateLimit in front of the | 
| 12 | 
            -
            `"lazy_blobs#show"` route because somebody could DOS your website | 
| 11 | 
            +
            You probably want to put a CDN/Cache/RateLimit in front of the
         | 
| 12 | 
            +
            `"lazy_blobs#show"` route because somebody could DOS your website
         | 
| 13 13 | 
             
            if all your workers are serving files from the database.
         | 
| 14 14 |  | 
| 15 | 
            -
            Basically this is a dumb idea, but setting up AWS buckets and permissions just | 
| 15 | 
            +
            Basically this is a dumb idea, but setting up AWS buckets and permissions just
         | 
| 16 16 | 
             
            to upload a dumb logo is :big_sigh_emoji:
         | 
| 17 17 |  | 
| 18 18 | 
             
            Don't use this. I mean it.
         | 
| 19 19 |  | 
| 20 | 
            +
            ## Alternative
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            I would use activestorage_database rather than lazy_blob_storage if I were starting a new project.
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            See:
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            - https://rubygems.org/gems/activestorage_database
         | 
| 27 | 
            +
            - https://github.com/WizardComputer/activestorage_database
         | 
| 28 | 
            +
             | 
| 20 29 | 
             
            ## Breaking Changes in 2.0.0-beta.1
         | 
| 21 30 |  | 
| 22 31 | 
             
            - Support UUID key types
         | 
| @@ -26,7 +26,7 @@ module LazyAttachable | |
| 26 26 |  | 
| 27 27 | 
             
                  define_method("validate_size_of_#{name}_upload") do
         | 
| 28 28 | 
             
                    if (send "#{name}_upload").present? && !(send "#{name}_upload_size_ok?")
         | 
| 29 | 
            -
                      errors.add("#{name}_upload",  | 
| 29 | 
            +
                      errors.add("#{name}_upload", LazyBlobStorage._max_blob_size_error_message)
         | 
| 30 30 | 
             
                    end
         | 
| 31 31 | 
             
                  end
         | 
| 32 32 |  | 
| @@ -1,11 +1,21 @@ | |
| 1 1 | 
             
            class CreateLazyVariants < ActiveRecord::Migration[7.0]
         | 
| 2 2 | 
             
              def change
         | 
| 3 | 
            -
                 | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
                primary_key_type, foreign_key_type = primary_and_foreign_key_types
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                create_table :lazy_variants, id: primary_key_type do |t|
         | 
| 6 | 
            +
                  t.references :lazy_attachment, type: foreign_key_type
         | 
| 7 | 
            +
                  t.references :lazy_blob, type: foreign_key_type
         | 
| 6 8 | 
             
                  t.string :name
         | 
| 7 9 | 
             
                  t.index :name
         | 
| 8 10 | 
             
                  t.timestamps
         | 
| 9 11 | 
             
                end
         | 
| 10 12 | 
             
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def primary_and_foreign_key_types
         | 
| 15 | 
            +
                config = Rails.configuration.generators
         | 
| 16 | 
            +
                setting = config.options[config.orm][:primary_key_type]
         | 
| 17 | 
            +
                primary_key_type = setting || :primary_key
         | 
| 18 | 
            +
                foreign_key_type = setting || :bigint
         | 
| 19 | 
            +
                [primary_key_type, foreign_key_type]
         | 
| 20 | 
            +
              end
         | 
| 11 21 | 
             
            end
         | 
    
        data/lib/lazy_blob_storage.rb
    CHANGED
    
    | @@ -2,12 +2,21 @@ require "lazy_blob_storage/engine" | |
| 2 2 |  | 
| 3 3 | 
             
            module LazyBlobStorage
         | 
| 4 4 | 
             
              mattr_accessor :max_blob_size
         | 
| 5 | 
            +
              mattr_accessor :max_blob_size_error_message
         | 
| 5 6 |  | 
| 6 7 | 
             
              def self.default_max_blob_size
         | 
| 7 8 | 
             
                100_000.bytes
         | 
| 8 9 | 
             
              end
         | 
| 9 10 |  | 
| 11 | 
            +
              def self.default_max_blob_size_error_message
         | 
| 12 | 
            +
                "file too large (limit #{_max_blob_size / 1_000} kb)"
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 10 15 | 
             
              def self._max_blob_size
         | 
| 11 16 | 
             
                max_blob_size || default_max_blob_size
         | 
| 12 17 | 
             
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def self._max_blob_size_error_message
         | 
| 20 | 
            +
                max_blob_size_error_message || default_max_blob_size_error_message
         | 
| 21 | 
            +
              end
         | 
| 13 22 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: lazy_blob_storage
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.0.0.pre.beta. | 
| 4 | 
            +
              version: 2.0.0.pre.beta.8
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Corey Smedstad
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023- | 
| 11 | 
            +
            date: 2023-04-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 154 154 | 
             
                - !ruby/object:Gem::Version
         | 
| 155 155 | 
             
                  version: 1.3.1
         | 
| 156 156 | 
             
            requirements: []
         | 
| 157 | 
            -
            rubygems_version: 3.4. | 
| 157 | 
            +
            rubygems_version: 3.4.10
         | 
| 158 158 | 
             
            signing_key:
         | 
| 159 159 | 
             
            specification_version: 4
         | 
| 160 160 | 
             
            summary: Low traffic site? Small file upload needs? Don't want to setup a cloud service?
         |