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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ff3df420c3918382cd60e6956cbba5839c545b83043e64ec034ca3603da74ee
4
- data.tar.gz: acb455a52cdee6e72de4eecf22e9aacf0bbd6f406c20941fcc78bacba4fa5149
3
+ metadata.gz: 0bd41b24bf9723782e729a80453c891b7997a1a254ec3020c966420fcf971fd5
4
+ data.tar.gz: 5936757ccfb7262de3caa1d3e1b9b5910e97561286d3895769d3b9cb9f5716dc
5
5
  SHA512:
6
- metadata.gz: 3a8f3e606cdf64e5b7b040917585a5f9a59d64b0d22cc2300ad20063b510cf651b0e979253f08379b4ef442b0bec7edcb9d926b5593c64bfe054a5a08857ca81
7
- data.tar.gz: 3368a9a65aed6487156585dbd54e63b87d4ae33c63e0bf8d13bdbcc451162839ad650fe70c769ac2aa7e016ab119979397e8563bb1a9af8772a912f682ddaa8f
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", "file too large (limit #{LazyBlobStorage._max_blob_size / 1_000} kb")
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
- create_table :lazy_variants do |t|
4
- t.references :lazy_attachment
5
- t.references :lazy_blob
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
@@ -1,3 +1,3 @@
1
1
  module LazyBlobStorage
2
- VERSION = "2.0.0-beta.6"
2
+ VERSION = "2.0.0-beta.8"
3
3
  end
@@ -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.6
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-03-10 00:00:00.000000000 Z
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.7
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?