active_storage_base64 2.0.0 → 3.0.1
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.
Potentially problematic release.
This version of active_storage_base64 might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +23 -1
- data/lib/active_storage_support/base64_attach.rb +1 -1
- data/lib/active_storage_support/support_for_base64.rb +9 -22
- metadata +38 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eba862394e004f3be34936eaa4154ea21f9dbe686101908b0aa97162cb758379
|
|
4
|
+
data.tar.gz: d03b6679e2f357ae0d68923854ae1345a076b20af5e7486a435ebc3caebcfe8a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0bbaf2b02e0b06f309a3a07700892a70ae115547c027d3bee9b5671650791a71e32014e1c4373a5d307c399e05d9285e31b01bfe1d1b19d065008681f6168e67
|
|
7
|
+
data.tar.gz: b04bde090fe974256791d4dedb282629ea0758dac12897b01f719df9e91c9e732c65288d802bcb193d2aa361f9717583176cc41a44dbc248e50513bfdd632edc
|
data/README.md
CHANGED
|
@@ -13,9 +13,21 @@ In order to get the gem working on your project you just need to add the gem to
|
|
|
13
13
|
gem 'active_storage_base64'
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## Compatibility
|
|
17
|
+
Rails Version | ActiveStorageBase64 Version
|
|
18
|
+
--------------|-----------------------------
|
|
19
|
+
8.1.x | 3.0.x
|
|
20
|
+
8.0.x | 3.0.x
|
|
21
|
+
7.2.x | 3.0.x
|
|
22
|
+
7.1.x | 3.0.x
|
|
23
|
+
7.0.x | 2.0.x
|
|
24
|
+
6.1.x | 1.2.x
|
|
25
|
+
6.0.x | 1.1.x
|
|
26
|
+
5.2.x | 0.1.x
|
|
27
|
+
|
|
16
28
|
## Prerequisites
|
|
17
29
|
|
|
18
|
-
The only
|
|
30
|
+
The only prerequisite for using this gem is having ActiveStorage properly set up in your project. For more information on how to do this, check [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html).
|
|
19
31
|
|
|
20
32
|
## Usage
|
|
21
33
|
|
|
@@ -169,6 +181,16 @@ For example:
|
|
|
169
181
|
data:image/png;base64,[base64 data]
|
|
170
182
|
```
|
|
171
183
|
|
|
184
|
+
### Avoid bloating logs
|
|
185
|
+
|
|
186
|
+
Because we use strings to pass data in params, if you are not careful, these long strings will show up in your production logs, causing a lot of bloat. To avoid this, filter your base64 params:
|
|
187
|
+
```diff
|
|
188
|
+
# config/initializers/filter_parameter_logging.rb
|
|
189
|
+
|
|
190
|
+
- Rails.application.config.filter_parameters += [:password]
|
|
191
|
+
+ Rails.application.config.filter_parameters += [:password, :avatar, :pictures, :file]
|
|
192
|
+
```
|
|
193
|
+
|
|
172
194
|
## Contributing
|
|
173
195
|
|
|
174
196
|
Please read our [CONTRIBUTING](https://github.com/rootstrap/active-storage-base64/blob/master/CONTRIBUTING.md) and our [CODE_OF_CONDUCT](https://github.com/rootstrap/active-storage-base64/blob/master/CODE_OF_CONDUCT.md) files for details on our code of conduct, and the process for submitting pull requests to us.
|
|
@@ -19,7 +19,7 @@ module ActiveStorageSupport
|
|
|
19
19
|
return unless base64_data.try(:is_a?, String) && base64_data.strip.start_with?('data')
|
|
20
20
|
|
|
21
21
|
headers, data = base64_data.split(',')
|
|
22
|
-
decoded_data = Base64.decode64(data)
|
|
22
|
+
decoded_data = Base64.decode64(data || '')
|
|
23
23
|
|
|
24
24
|
attachment[:io] = StringIO.new(decoded_data)
|
|
25
25
|
attachment[:content_type] ||= content_type(headers)
|
|
@@ -17,7 +17,7 @@ module ActiveStorageSupport
|
|
|
17
17
|
|
|
18
18
|
def #{name}=(attachable)
|
|
19
19
|
attachment_changes["#{name}"] =
|
|
20
|
-
if attachable.nil?
|
|
20
|
+
if attachable.nil? || attachable == ""
|
|
21
21
|
ActiveStorage::Attached::Changes::DeleteOne.new("#{name}", self)
|
|
22
22
|
else
|
|
23
23
|
ActiveStorage::Attached::Changes::CreateOne.new(
|
|
@@ -39,28 +39,15 @@ module ActiveStorageSupport
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def #{name}=(attachables)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if Array(attachables).none?
|
|
45
|
-
ActiveStorage::Attached::Changes::DeleteMany.new("#{name}", self)
|
|
46
|
-
else
|
|
47
|
-
ActiveStorage::Attached::Changes::CreateMany.new(
|
|
48
|
-
"#{name}", self, ActiveStorageSupport::Base64Many.from_base64(attachables)
|
|
49
|
-
)
|
|
50
|
-
end
|
|
51
|
-
else
|
|
52
|
-
ActiveSupport::Deprecation.warn \
|
|
53
|
-
"config.active_storage.replace_on_assign_to_many is deprecated and will be removed in Rails 7.1. " \
|
|
54
|
-
"Make sure that your code works well with config.active_storage.replace_on_assign_to_many set to true before upgrading. " \
|
|
55
|
-
"To append new attachables to the Active Storage association, prefer using `attach`. " \
|
|
56
|
-
"Using association setter would result in purging the existing attached attachments and replacing them with new ones."
|
|
42
|
+
attachables = Array(attachables).compact_blank
|
|
43
|
+
pending_uploads = attachment_changes["#{name}"].try(:pending_uploads)
|
|
57
44
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
45
|
+
attachment_changes["#{name}"] = if attachables.none?
|
|
46
|
+
ActiveStorage::Attached::Changes::DeleteMany.new("#{name}", self)
|
|
47
|
+
else
|
|
48
|
+
ActiveStorage::Attached::Changes::CreateMany.new(
|
|
49
|
+
"#{name}", self, ActiveStorageSupport::Base64Many.from_base64(attachables), pending_uploads: pending_uploads
|
|
50
|
+
)
|
|
64
51
|
end
|
|
65
52
|
end
|
|
66
53
|
CODE
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_storage_base64
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ricardo Cortio
|
|
@@ -9,20 +9,48 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2025-08-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
15
|
+
name: activestorage
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
requirements:
|
|
18
|
-
- - "
|
|
18
|
+
- - ">"
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
20
|
version: '7.0'
|
|
21
21
|
type: :runtime
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
|
-
- - "
|
|
25
|
+
- - ">"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '7.0'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: activesupport
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '7.0'
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '7.0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: rails
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">"
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '7.0'
|
|
49
|
+
type: :development
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">"
|
|
26
54
|
- !ruby/object:Gem::Version
|
|
27
55
|
version: '7.0'
|
|
28
56
|
- !ruby/object:Gem::Dependency
|
|
@@ -99,16 +127,16 @@ dependencies:
|
|
|
99
127
|
name: sqlite3
|
|
100
128
|
requirement: !ruby/object:Gem::Requirement
|
|
101
129
|
requirements:
|
|
102
|
-
- -
|
|
130
|
+
- - ">="
|
|
103
131
|
- !ruby/object:Gem::Version
|
|
104
|
-
version:
|
|
132
|
+
version: '0'
|
|
105
133
|
type: :development
|
|
106
134
|
prerelease: false
|
|
107
135
|
version_requirements: !ruby/object:Gem::Requirement
|
|
108
136
|
requirements:
|
|
109
|
-
- -
|
|
137
|
+
- - ">="
|
|
110
138
|
- !ruby/object:Gem::Version
|
|
111
|
-
version:
|
|
139
|
+
version: '0'
|
|
112
140
|
- !ruby/object:Gem::Dependency
|
|
113
141
|
name: image_processing
|
|
114
142
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -157,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
157
185
|
- !ruby/object:Gem::Version
|
|
158
186
|
version: '0'
|
|
159
187
|
requirements: []
|
|
160
|
-
rubygems_version: 3.0.3
|
|
188
|
+
rubygems_version: 3.0.3.1
|
|
161
189
|
signing_key:
|
|
162
190
|
specification_version: 4
|
|
163
191
|
summary: Base64 support for ActiveStorage
|