paperclip 4.3.7 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +17 -0
- data/.github/issue_template.md +3 -0
- data/.hound.yml +5 -16
- data/.travis.yml +15 -12
- data/Appraisals +4 -8
- data/CONTRIBUTING.md +16 -5
- data/Gemfile +3 -8
- data/LICENSE +1 -1
- data/MIGRATING-ES.md +317 -0
- data/MIGRATING.md +375 -0
- data/NEWS +126 -31
- data/README.md +264 -156
- data/Rakefile +1 -1
- data/UPGRADING +12 -9
- data/features/basic_integration.feature +3 -2
- data/features/migration.feature +0 -24
- data/features/step_definitions/attachment_steps.rb +14 -14
- data/features/step_definitions/rails_steps.rb +29 -28
- data/features/step_definitions/s3_steps.rb +2 -2
- data/features/support/env.rb +1 -0
- data/features/support/paths.rb +1 -1
- data/features/support/rails.rb +0 -24
- data/gemfiles/4.2.gemfile +3 -5
- data/gemfiles/{3.2.gemfile → 5.0.gemfile} +4 -6
- data/lib/generators/paperclip/paperclip_generator.rb +9 -1
- data/lib/generators/paperclip/templates/paperclip_migration.rb.erb +1 -1
- data/lib/paperclip.rb +14 -12
- data/lib/paperclip/attachment.rb +44 -20
- data/lib/paperclip/attachment_registry.rb +2 -1
- data/lib/paperclip/callbacks.rb +8 -6
- data/lib/paperclip/content_type_detector.rb +3 -2
- data/lib/paperclip/errors.rb +3 -1
- data/lib/paperclip/file_command_content_type_detector.rb +1 -1
- data/lib/paperclip/filename_cleaner.rb +0 -1
- data/lib/paperclip/geometry_detector_factory.rb +3 -3
- data/lib/paperclip/glue.rb +1 -1
- data/lib/paperclip/has_attached_file.rb +7 -1
- data/lib/paperclip/helpers.rb +15 -11
- data/lib/paperclip/interpolations.rb +7 -2
- data/lib/paperclip/io_adapters/abstract_adapter.rb +31 -4
- data/lib/paperclip/io_adapters/attachment_adapter.rb +17 -6
- data/lib/paperclip/io_adapters/data_uri_adapter.rb +8 -8
- data/lib/paperclip/io_adapters/empty_string_adapter.rb +5 -4
- data/lib/paperclip/io_adapters/file_adapter.rb +12 -6
- data/lib/paperclip/io_adapters/http_url_proxy_adapter.rb +8 -7
- data/lib/paperclip/io_adapters/identity_adapter.rb +12 -6
- data/lib/paperclip/io_adapters/nil_adapter.rb +8 -5
- data/lib/paperclip/io_adapters/registry.rb +6 -2
- data/lib/paperclip/io_adapters/stringio_adapter.rb +9 -6
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +10 -6
- data/lib/paperclip/io_adapters/uri_adapter.rb +22 -17
- data/lib/paperclip/logger.rb +1 -1
- data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rb +4 -4
- data/lib/paperclip/media_type_spoof_detector.rb +11 -7
- data/lib/paperclip/processor.rb +15 -6
- data/lib/paperclip/schema.rb +3 -9
- data/lib/paperclip/storage/filesystem.rb +13 -2
- data/lib/paperclip/storage/fog.rb +21 -14
- data/lib/paperclip/storage/s3.rb +81 -61
- data/lib/paperclip/style.rb +0 -1
- data/lib/paperclip/thumbnail.rb +22 -9
- data/lib/paperclip/url_generator.rb +17 -13
- data/lib/paperclip/validators.rb +1 -1
- data/lib/paperclip/validators/attachment_size_validator.rb +1 -7
- data/lib/paperclip/validators/media_type_spoof_detection_validator.rb +4 -0
- data/lib/paperclip/version.rb +3 -1
- data/lib/tasks/paperclip.rake +18 -4
- data/paperclip.gemspec +13 -10
- data/spec/paperclip/attachment_processing_spec.rb +2 -5
- data/spec/paperclip/attachment_registry_spec.rb +28 -0
- data/spec/paperclip/attachment_spec.rb +89 -20
- data/spec/paperclip/content_type_detector_spec.rb +1 -1
- data/spec/paperclip/file_command_content_type_detector_spec.rb +15 -1
- data/spec/paperclip/filename_cleaner_spec.rb +0 -1
- data/spec/paperclip/has_attached_file_spec.rb +24 -8
- data/spec/paperclip/integration_spec.rb +42 -5
- data/spec/paperclip/interpolations_spec.rb +9 -0
- data/spec/paperclip/io_adapters/abstract_adapter_spec.rb +104 -22
- data/spec/paperclip/io_adapters/attachment_adapter_spec.rb +6 -3
- data/spec/paperclip/io_adapters/data_uri_adapter_spec.rb +7 -1
- data/spec/paperclip/io_adapters/file_adapter_spec.rb +2 -2
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +47 -13
- data/spec/paperclip/io_adapters/identity_adapter_spec.rb +1 -1
- data/spec/paperclip/io_adapters/registry_spec.rb +2 -2
- data/spec/paperclip/io_adapters/stringio_adapter_spec.rb +1 -1
- data/spec/paperclip/io_adapters/uploaded_file_adapter_spec.rb +5 -5
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +104 -11
- data/spec/paperclip/matchers/validate_attachment_content_type_matcher_spec.rb +10 -0
- data/spec/paperclip/matchers/validate_attachment_size_matcher_spec.rb +1 -1
- data/spec/paperclip/media_type_spoof_detector_spec.rb +41 -0
- data/spec/paperclip/paperclip_spec.rb +15 -45
- data/spec/paperclip/processor_spec.rb +4 -4
- data/spec/paperclip/schema_spec.rb +46 -46
- data/spec/paperclip/storage/fog_spec.rb +31 -0
- data/spec/paperclip/storage/s3_live_spec.rb +20 -14
- data/spec/paperclip/storage/s3_spec.rb +359 -192
- data/spec/paperclip/style_spec.rb +0 -1
- data/spec/paperclip/tempfile_spec.rb +35 -0
- data/spec/paperclip/thumbnail_spec.rb +43 -38
- data/spec/paperclip/url_generator_spec.rb +54 -44
- data/spec/paperclip/validators/attachment_size_validator_spec.rb +26 -20
- data/spec/paperclip/validators_spec.rb +5 -5
- data/spec/spec_helper.rb +5 -2
- data/spec/support/assertions.rb +12 -1
- data/spec/support/mock_attachment.rb +2 -0
- data/spec/support/mock_url_generator_builder.rb +2 -2
- data/spec/support/model_reconstruction.rb +11 -3
- data/spec/support/reporting.rb +11 -0
- metadata +64 -61
- data/cucumber/paperclip_steps.rb +0 -6
- data/gemfiles/4.1.gemfile +0 -19
- data/lib/paperclip/deprecations.rb +0 -42
- data/lib/paperclip/locales/de.yml +0 -18
- data/lib/paperclip/locales/es.yml +0 -18
- data/lib/paperclip/locales/ja.yml +0 -18
- data/lib/paperclip/locales/pt-BR.yml +0 -18
- data/lib/paperclip/locales/zh-CN.yml +0 -18
- data/lib/paperclip/locales/zh-HK.yml +0 -18
- data/lib/paperclip/locales/zh-TW.yml +0 -18
- data/spec/paperclip/deprecations_spec.rb +0 -65
- data/spec/support/deprecations.rb +0 -9
- data/spec/support/rails_helpers.rb +0 -7
data/MIGRATING.md
ADDED
@@ -0,0 +1,375 @@
|
|
1
|
+
# Migrating from Paperclip to ActiveStorage
|
2
|
+
|
3
|
+
Paperclip and ActiveStorage solve similar problems with similar solutions, so
|
4
|
+
transitioning from one to the other is straightforward data re-writing.
|
5
|
+
|
6
|
+
The process of going from Paperclip to ActiveStorage is as follows:
|
7
|
+
|
8
|
+
1. Apply the ActiveStorage database migrations.
|
9
|
+
2. Configure storage.
|
10
|
+
3. Copy the database data over.
|
11
|
+
4. Copy the files over.
|
12
|
+
5. Update your tests.
|
13
|
+
6. Update your views.
|
14
|
+
7. Update your controllers.
|
15
|
+
8. Update your models.
|
16
|
+
|
17
|
+
## Apply the ActiveStorage database migrations
|
18
|
+
|
19
|
+
Follow [the instructions for installing ActiveStorage]. You'll very likely want
|
20
|
+
to add the `mini_magick` gem to your Gemfile.
|
21
|
+
|
22
|
+
```sh
|
23
|
+
rails active_storage:install
|
24
|
+
```
|
25
|
+
|
26
|
+
[the instructions for installing ActiveStorage]: https://github.com/rails/rails/blob/master/activestorage/README.md#installation
|
27
|
+
|
28
|
+
## Configure storage
|
29
|
+
|
30
|
+
Again, follow [the instructions for configuring ActiveStorage].
|
31
|
+
|
32
|
+
[the instructions for configuring ActiveStorage]: http://edgeguides.rubyonrails.org/active_storage_overview.html#setup
|
33
|
+
|
34
|
+
## Copy the database data over
|
35
|
+
|
36
|
+
The `active_storage_blobs` and `active_storage_attachments` tables are where
|
37
|
+
ActiveStorage expects to find file metadata. Paperclip stores the file metadata
|
38
|
+
directly on the associated object's table.
|
39
|
+
|
40
|
+
You'll need to write a migration for this conversion. Because the models for
|
41
|
+
your domain are involved, it's tricky to supply a simple script. But we'll try!
|
42
|
+
|
43
|
+
Here's how it would go for a `User` with an `avatar`, that is this in
|
44
|
+
Paperclip:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
class User < ApplicationRecord
|
48
|
+
has_attached_file :avatar
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
Your Paperclip migrations will produce a table like so:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
create_table "users", force: :cascade do |t|
|
56
|
+
t.string "avatar_file_name"
|
57
|
+
t.string "avatar_content_type"
|
58
|
+
t.integer "avatar_file_size"
|
59
|
+
t.datetime "avatar_updated_at"
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
And you'll be converting into these tables:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
create_table "active_storage_attachments", force: :cascade do |t|
|
67
|
+
t.string "name", null: false
|
68
|
+
t.string "record_type", null: false
|
69
|
+
t.integer "record_id", null: false
|
70
|
+
t.integer "blob_id", null: false
|
71
|
+
t.datetime "created_at", null: false
|
72
|
+
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
73
|
+
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
create_table "active_storage_blobs", force: :cascade do |t|
|
79
|
+
t.string "key", null: false
|
80
|
+
t.string "filename", null: false
|
81
|
+
t.string "content_type"
|
82
|
+
t.text "metadata"
|
83
|
+
t.bigint "byte_size", null: false
|
84
|
+
t.string "checksum", null: false
|
85
|
+
t.datetime "created_at", null: false
|
86
|
+
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
So, assuming you want to leave the files in the exact same place, _this is
|
91
|
+
your migration_. Otherwise, see the next section first and modify the migration
|
92
|
+
to taste.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
Dir[Rails.root.join("app/models/**/*.rb")].sort.each { |file| require file }
|
96
|
+
|
97
|
+
class ConvertToActiveStorage < ActiveRecord::Migration[5.2]
|
98
|
+
require 'open-uri'
|
99
|
+
|
100
|
+
def up
|
101
|
+
# postgres
|
102
|
+
get_blob_id = 'LASTVAL()'
|
103
|
+
# mariadb
|
104
|
+
# get_blob_id = 'LAST_INSERT_ID()'
|
105
|
+
# sqlite
|
106
|
+
# get_blob_id = 'LAST_INSERT_ROWID()'
|
107
|
+
|
108
|
+
active_storage_blob_statement = ActiveRecord::Base.connection.raw_connection.prepare(<<-SQL)
|
109
|
+
INSERT INTO active_storage_blobs (
|
110
|
+
`key`, filename, content_type, metadata, byte_size, checksum, created_at
|
111
|
+
) VALUES (?, ?, ?, '{}', ?, ?, ?)
|
112
|
+
SQL
|
113
|
+
|
114
|
+
active_storage_attachment_statement = ActiveRecord::Base.connection.raw_connection.prepare(<<-SQL)
|
115
|
+
INSERT INTO active_storage_attachments (
|
116
|
+
name, record_type, record_id, blob_id, created_at
|
117
|
+
) VALUES (?, ?, ?, #{get_blob_id}, ?)
|
118
|
+
SQL
|
119
|
+
|
120
|
+
models = ActiveRecord::Base.descendants.reject(&:abstract_class?)
|
121
|
+
|
122
|
+
transaction do
|
123
|
+
models.each do |model|
|
124
|
+
attachments = model.column_names.map do |c|
|
125
|
+
if c =~ /(.+)_file_name$/
|
126
|
+
$1
|
127
|
+
end
|
128
|
+
end.compact
|
129
|
+
|
130
|
+
model.find_each.each do |instance|
|
131
|
+
attachments.each do |attachment|
|
132
|
+
active_storage_blob_statement.execute(
|
133
|
+
key(instance, attachment),
|
134
|
+
instance.send("#{attachment}_file_name"),
|
135
|
+
instance.send("#{attachment}_content_type"),
|
136
|
+
instance.send("#{attachment}_file_size"),
|
137
|
+
checksum(instance.send(attachment)),
|
138
|
+
instance.updated_at.iso8601
|
139
|
+
)
|
140
|
+
|
141
|
+
active_storage_attachment_statement.
|
142
|
+
execute(attachment, model.name, instance.id, instance.updated_at.iso8601)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
active_storage_attachment_statement.close
|
149
|
+
active_storage_blob_statement.close
|
150
|
+
end
|
151
|
+
|
152
|
+
def down
|
153
|
+
raise ActiveRecord::IrreversibleMigration
|
154
|
+
end
|
155
|
+
|
156
|
+
private
|
157
|
+
|
158
|
+
def key(instance, attachment)
|
159
|
+
SecureRandom.uuid
|
160
|
+
# Alternatively:
|
161
|
+
# instance.send("#{attachment}_file_name")
|
162
|
+
end
|
163
|
+
|
164
|
+
def checksum(attachment)
|
165
|
+
# local files stored on disk:
|
166
|
+
url = attachment.path
|
167
|
+
Digest::MD5.base64digest(File.read(url))
|
168
|
+
|
169
|
+
# remote files stored on another person's computer:
|
170
|
+
# url = attachment.url
|
171
|
+
# Digest::MD5.base64digest(Net::HTTP.get(URI(url)))
|
172
|
+
end
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
176
|
+
## Copy the files over
|
177
|
+
|
178
|
+
The above migration leaves the files as they are. However, the default
|
179
|
+
Paperclip and ActiveStorage storage services use different locations.
|
180
|
+
|
181
|
+
By default, Paperclip looks like this:
|
182
|
+
|
183
|
+
```
|
184
|
+
public/system/users/avatars/000/000/004/original/the-mystery-of-life.png
|
185
|
+
```
|
186
|
+
|
187
|
+
And ActiveStorage looks like this:
|
188
|
+
|
189
|
+
```
|
190
|
+
storage/xM/RX/xMRXuT6nqpoiConJFQJFt6c9
|
191
|
+
```
|
192
|
+
|
193
|
+
That `xMRXuT6nqpoiConJFQJFt6c9` is the `active_storage_blobs.key` value. In the
|
194
|
+
migration above we simply used the filename but you may wish to use a UUID
|
195
|
+
instead.
|
196
|
+
|
197
|
+
|
198
|
+
### Moving local storage files
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
#!bin/rails runner
|
202
|
+
|
203
|
+
class ActiveStorageBlob < ActiveRecord::Base
|
204
|
+
end
|
205
|
+
|
206
|
+
class ActiveStorageAttachment < ActiveRecord::Base
|
207
|
+
belongs_to :blob, class_name: 'ActiveStorageBlob'
|
208
|
+
belongs_to :record, polymorphic: true
|
209
|
+
end
|
210
|
+
|
211
|
+
ActiveStorageAttachment.find_each do |attachment|
|
212
|
+
name = attachment.name
|
213
|
+
|
214
|
+
source = attachment.record.send(name).path
|
215
|
+
dest_dir = File.join(
|
216
|
+
"storage",
|
217
|
+
attachment.blob.key.first(2),
|
218
|
+
attachment.blob.key.first(4).last(2))
|
219
|
+
dest = File.join(dest_dir, attachment.blob.key)
|
220
|
+
|
221
|
+
FileUtils.mkdir_p(dest_dir)
|
222
|
+
puts "Moving #{source} to #{dest}"
|
223
|
+
FileUtils.cp(source, dest)
|
224
|
+
end
|
225
|
+
```
|
226
|
+
|
227
|
+
### Moving files on a remote host (S3, Azure Storage, GCS, etc.)
|
228
|
+
|
229
|
+
One of the most straightforward ways to move assets stored on a remote host is
|
230
|
+
to use a rake task that regenerates the file names and places them in the
|
231
|
+
proper file structure/hierarchy.
|
232
|
+
|
233
|
+
Assuming you have a model configured similarly to the example below:
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
class Organization < ApplicationRecord
|
237
|
+
# New ActiveStorage declaration
|
238
|
+
has_one_attached :logo
|
239
|
+
|
240
|
+
# Old Paperclip config
|
241
|
+
# must be removed BEFORE to running the rake task so that
|
242
|
+
# all of the new ActiveStorage goodness can be used when
|
243
|
+
# calling organization.logo
|
244
|
+
has_attached_file :logo,
|
245
|
+
path: "/organizations/:id/:basename_:style.:extension",
|
246
|
+
default_url: "https://s3.amazonaws.com/xxxxx/organizations/missing_:style.jpg",
|
247
|
+
default_style: :normal,
|
248
|
+
styles: { thumb: "64x64#", normal: "400x400>" },
|
249
|
+
convert_options: { thumb: "-quality 100 -strip", normal: "-quality 75 -strip" }
|
250
|
+
end
|
251
|
+
```
|
252
|
+
|
253
|
+
The following rake task would migrate all of your assets:
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
namespace :organizations do
|
257
|
+
task migrate_to_active_storage: :environment do
|
258
|
+
Organization.where.not(logo_file_name: nil).find_each do |organization|
|
259
|
+
# This step helps us catch any attachments we might have uploaded that
|
260
|
+
# don't have an explicit file extension in the filename
|
261
|
+
image = organization.logo_file_name
|
262
|
+
ext = File.extname(image)
|
263
|
+
image_original = URI.unescape(image.gsub(ext, "_original#{ext}"))
|
264
|
+
|
265
|
+
# this url pattern can be changed to reflect whatever service you use
|
266
|
+
logo_url = "https://s3.amazonaws.com/xxxxx/organizations/#{organization.id}/#{image_original}"
|
267
|
+
organization.logo.attach(io: open(logo_url),
|
268
|
+
filename: organization.logo_file_name,
|
269
|
+
content_type: organization.logo_content_type)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
```
|
274
|
+
|
275
|
+
An added advantage of this method is that you're creating a copy of all assets,
|
276
|
+
which is handy in the event you need to rollback your deploy.
|
277
|
+
|
278
|
+
This also means that you can run the rake task from your development machine
|
279
|
+
and completely migrate the assets before your deploy, minimizing the chances
|
280
|
+
that you'll have a timed-out deployment.
|
281
|
+
|
282
|
+
The main drawback of this method is the same as its benefit - you are
|
283
|
+
essentially duplicating all of your assets. These days storage and bandwidth
|
284
|
+
are relatively cheap, but in some instances where you have a huge volume of
|
285
|
+
files, or very large file sizes, this might get a little less feasible.
|
286
|
+
|
287
|
+
In my experience I was able to move tens of thousands of images in a matter of
|
288
|
+
a couple of hours, just by running the migration overnight on my MacBook Pro.
|
289
|
+
|
290
|
+
Once you've confirmed that the migration and deploy have gone successfully you
|
291
|
+
can safely delete the old assets from your remote host.
|
292
|
+
|
293
|
+
## Update your tests
|
294
|
+
|
295
|
+
Instead of the `have_attached_file` matcher, you'll need to write your own.
|
296
|
+
Here's one that is similar in spirit to the Paperclip-supplied matcher:
|
297
|
+
|
298
|
+
```ruby
|
299
|
+
RSpec::Matchers.define :have_attached_file do |name|
|
300
|
+
matches do |record|
|
301
|
+
file = record.send(name)
|
302
|
+
file.respond_to?(:variant) && file.respond_to?(:attach)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
```
|
306
|
+
|
307
|
+
## Update your views
|
308
|
+
|
309
|
+
In Paperclip it looks like this:
|
310
|
+
|
311
|
+
```ruby
|
312
|
+
image_tag @user.avatar.url(:medium)
|
313
|
+
```
|
314
|
+
|
315
|
+
In ActiveStorage it looks like this:
|
316
|
+
|
317
|
+
```ruby
|
318
|
+
image_tag @user.avatar.variant(resize: "250x250")
|
319
|
+
```
|
320
|
+
|
321
|
+
## Update your controllers
|
322
|
+
|
323
|
+
This should _require_ no update. However, if you glance back at the database
|
324
|
+
schema above, you may notice a join.
|
325
|
+
|
326
|
+
For example, if your controller has
|
327
|
+
|
328
|
+
```ruby
|
329
|
+
def index
|
330
|
+
@users = User.all.order(:name)
|
331
|
+
end
|
332
|
+
```
|
333
|
+
|
334
|
+
And your view has
|
335
|
+
|
336
|
+
```
|
337
|
+
<ul>
|
338
|
+
<% @users.each do |user| %>
|
339
|
+
<li><%= image_tag user.avatar.variant(resize: "10x10"), alt: user.name %></li>
|
340
|
+
<% end %>
|
341
|
+
</ul>
|
342
|
+
```
|
343
|
+
|
344
|
+
Then you'll end up with an n+1 as you load each attachment in the loop.
|
345
|
+
|
346
|
+
So while the controller and model will work without change, you will want to
|
347
|
+
double-check your loops and add `includes` as needed. ActiveStorage adds an
|
348
|
+
`avatar_attachment` and `avatar_blob` relationship to has-one relations, and
|
349
|
+
`avatar_attachments` and `avatar_blobs` to has-many:
|
350
|
+
|
351
|
+
```ruby
|
352
|
+
def index
|
353
|
+
@users = User.all.order(:name).includes(:avatar_attachment)
|
354
|
+
end
|
355
|
+
```
|
356
|
+
|
357
|
+
## Update your models
|
358
|
+
|
359
|
+
Follow [the guide on attaching files to records]. For example, a `User` with an
|
360
|
+
`avatar` is represented as:
|
361
|
+
|
362
|
+
```ruby
|
363
|
+
class User < ApplicationRecord
|
364
|
+
has_one_attached :avatar
|
365
|
+
end
|
366
|
+
```
|
367
|
+
|
368
|
+
Any resizing is done in the view as a variant.
|
369
|
+
|
370
|
+
[the guide on attaching files to records]: http://edgeguides.rubyonrails.org/active_storage_overview.html#attaching-files-to-records
|
371
|
+
|
372
|
+
## Remove Paperclip
|
373
|
+
|
374
|
+
Remove the Gem from your `Gemfile` and run `bundle`. Run your tests because
|
375
|
+
you're done!
|
data/NEWS
CHANGED
@@ -1,39 +1,134 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
*
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
6.1.0 (2018-07-27):
|
2
|
+
|
3
|
+
* BUGFIX: Don't double-encode URLs (Roderick Monje).
|
4
|
+
* BUGFIX: Only use the content_type when it exists (Jean-Philippe Doyle).
|
5
|
+
* STABILITY: Better handling of the content-disposition header. Now supports
|
6
|
+
file name that is either enclosed or not in double quotes and is case
|
7
|
+
insensitive as per RC6266 grammar (Hasan Kumar, Yves Riel).
|
8
|
+
* STABILITY: Change database column type of attachment file size from unsigned 4-byte
|
9
|
+
`integer` to unsigned 8-byte `bigint`. The former type limits attachment size
|
10
|
+
to just over 2GB, which can easily be exceeded by a large video file (Laurent
|
11
|
+
Arnoud, Alen Zamanyan).
|
12
|
+
* STABILITY: Better error message when thumbnail processing errors (Hayden Ball).
|
13
|
+
* STABILITY: Fix file linking issues around Windows (Akihiko Odaki).
|
14
|
+
* STABILITY: Files without an extension will now be checked for spoofing attempts
|
15
|
+
(George Walters II).
|
16
|
+
* STABILITY: Manually close Tempfiles when we are done with them (Erkki Eilonen).
|
17
|
+
|
18
|
+
6.0.0 (2018-03-09):
|
19
|
+
|
20
|
+
* Improvement: Depend only on `aws-sdk-s3` instead of `aws-sdk` (https://github.com/thoughtbot/paperclip/pull/2481)
|
21
|
+
|
22
|
+
5.3.0 (2018-03-09):
|
23
|
+
|
24
|
+
* Improvement: Use `FactoryBot` instead of `FactoryGirl` (https://github.com/thoughtbot/paperclip/pull/2501)
|
25
|
+
* Improvement: README updates (https://github.com/thoughtbot/paperclip/pull/2411, https://github.com/thoughtbot/paperclip/pull/2433, https://github.com/thoughtbot/paperclip/pull/2374, https://github.com/thoughtbot/paperclip/pull/2417, https://github.com/thoughtbot/paperclip/pull/2536)
|
26
|
+
* Improvement: Remove Ruby 2.4 deprecation warning (https://github.com/thoughtbot/paperclip/pull/2401)
|
27
|
+
* Improvement: Rails 5 migration compatibility (https://github.com/thoughtbot/paperclip/pull/2470)
|
28
|
+
* Improvement: Documentation around post processing (https://github.com/thoughtbot/paperclip/pull/2381)
|
29
|
+
* Improvement: S3 hostname example documentation (https://github.com/thoughtbot/paperclip/pull/2379)
|
30
|
+
* Bugfix: Allow paperclip to load in IRB (https://github.com/thoughtbot/paperclip/pull/2369)
|
31
|
+
* Bugfix: MIME type detection (https://github.com/thoughtbot/paperclip/issues/2527)
|
32
|
+
* Bugfix: Bad tempfile state after symlink failure (https://github.com/thoughtbot/paperclip/pull/2540)
|
33
|
+
* Bugfix: Rewind file after Fog bucket creation (https://github.com/thoughtbot/paperclip/pull/2572)
|
34
|
+
* Improvement: Use `Terrapin` instead of `Cocaine` (https://github.com/thoughtbot/paperclip/pull/2553)
|
35
|
+
|
36
|
+
5.2.1 (2018-01-25):
|
37
|
+
|
38
|
+
* Bugfix: Fix copying files on Windows. (#2532)
|
39
|
+
|
40
|
+
5.2.0 (2018-01-23):
|
41
|
+
|
42
|
+
* Security: Remove the automatic loading of URI adapters. Some of these
|
43
|
+
adapters can be specially crafted to expose your network topology. (#2435)
|
44
|
+
* Bugfix: The rake task no longer rescues `Exception`. (#2476)
|
45
|
+
* Bugfix: Handle malformed `Content-Disposition` headers (#2283)
|
46
|
+
* Bugfix: The `:only_process` option works when passed a lambda again. (#2289)
|
47
|
+
* Improvement: Added `:use_accelerate_endpoint` option when using S3 to enable
|
48
|
+
[Amazon S3 Transfer Acceleration](http://docs.aws.amazon.com/AmazonS3/latest/dev/transfer-acceleration.html)
|
49
|
+
(#2291)
|
50
|
+
* Improvement: Make the fingerprint digest configurable per attachment. The
|
51
|
+
default remains MD5. Making this configurable means it can change in a future
|
52
|
+
version because it is not considered secure anymore against intentional file
|
53
|
+
corruption. For more info, see https://en.wikipedia.org/wiki/MD5#Security
|
54
|
+
|
55
|
+
You can change the digest used for an attachment by adding the
|
56
|
+
`:adapter_options` parameter to the `has_attached_file` options like this:
|
57
|
+
`has_attached_file :avatar, adapter_options: { hash_digest: Digest::SHA256 }`
|
58
|
+
|
59
|
+
Use the rake task to regenerate fingerprints with the new digest for a given
|
60
|
+
class. Note that this does **not** check the file integrity using the old
|
61
|
+
fingerprint. Run the following command to regenerate fingerprints for all
|
62
|
+
User attachments:
|
63
|
+
`CLASS=User rake paperclip:refresh:fingerprints`
|
64
|
+
You can optionally limit the attachment that will be processed, e.g:
|
65
|
+
`CLASS=User ATTACHMENT=avatar rake paperclip:refresh:fingerprints` (#2229)
|
66
|
+
* Improvement: The new `frame_index` option on the thumbnail processor allows
|
67
|
+
you to select a specific frame from an animated upload to use as a thumbnail.
|
68
|
+
Initial support is for mkv, avi, MP4, mov, MPEG, and GIF. (#2155)
|
69
|
+
* Improvement: Instead of copying files, use hard links. This is an
|
70
|
+
optimization. (#2120)
|
71
|
+
* Improvement: S3 storage option `:s3_prefixes_in_alias`. (#2287)
|
72
|
+
* Improvement: Fog option `:fog_public` can be a lambda. (#2302)
|
73
|
+
* Improvement: One fewer warning on JRuby. (#2352)
|
74
|
+
* Ruby 2.4.0 compatibility (doesn't use Fixnum anymore)
|
75
|
+
|
76
|
+
5.1.0 (2016-08-19):
|
77
|
+
|
78
|
+
* Add default `content_type_detector` to `UploadedFileAdapter` (#2270)
|
79
|
+
* Default S3 protocol to empty string (#2038)
|
80
|
+
* Don't write original file if it wasn't reprocessed (#1993)
|
81
|
+
* Disallow trailing newlines in regular expressions (#2266)
|
82
|
+
* Support for readbyte in Paperclip attachments (#2034)
|
83
|
+
* (port from 4.3) Uri io adapter uses the content-disposition filename (#2250)
|
84
|
+
* General refactors and documentation improvements
|
85
|
+
|
86
|
+
5.0.0 (2016-07-01):
|
87
|
+
|
88
|
+
* Improvement: Add `read_timeout` configuration for URI Adapter download_content method.
|
89
|
+
* README adjustments for Ruby beginners (add links, elucidate model in Quick Start)
|
90
|
+
* Bugfix: Now it's possible to save images from URLs with special characters [#1932]
|
91
|
+
* Bugfix: Return false when file to copy is not present in cloud storage [#2173]
|
92
|
+
* Automatically close file while checking mime type [#2016]
|
93
|
+
* Add `read_timeout` option to `UriAdapter#download_content` method [#2232]
|
94
|
+
* Fix a nil error in content type validation matcher [#1910]
|
95
|
+
* Documentation improvements
|
96
|
+
|
97
|
+
5.0.0.beta2 (2016-04-01):
|
98
|
+
|
99
|
+
* Bugfix: Dynamic fog directory option is now respected
|
100
|
+
* Bugfix: Fixes cocaine duplicated paths [#2169]
|
101
|
+
* Removal of dead code (older versions of Rails and AWS SDK)
|
102
|
+
* README adjustments
|
20
103
|
|
21
|
-
|
104
|
+
5.0.0.beta1 (2016-03-13):
|
22
105
|
|
23
|
-
|
106
|
+
* Bug Fix: megabytes of mime-types info in logs when a spoofed media type is detected.
|
107
|
+
* Drop support to end-of-life'd ruby 2.0.
|
108
|
+
* Drop support for end-of-life'd Rails 3.2 and 4.1
|
109
|
+
* Drop support for AWS v1
|
110
|
+
* Remove tests for JRuby and Rubinius from Travis CI (they were failing)
|
111
|
+
* Improvement: Add `fog_options` configuration to send options to fog when
|
112
|
+
storing files.
|
113
|
+
* Extracted repository for locales only: https://github.com/thoughtbot/paperclip-i18n
|
114
|
+
* Bugfix: Original file could be unlinked during `post_process_style`, producing failures
|
115
|
+
* Bugfix for image magick scaling images up
|
116
|
+
* Memory consumption improvements
|
117
|
+
* `url` on a unpersisted record returns `default_url` rather than `nil`
|
118
|
+
* Improvement: aws-sdk v2 support
|
119
|
+
https://github.com/thoughtbot/paperclip/pull/1903
|
24
120
|
|
25
|
-
|
121
|
+
If your Gemfile contains aws-sdk (>= 2.0.0) and aws-sdk-v1, paperclip will use
|
122
|
+
aws-sdk v2. With aws-sdk v2, S3 storage requires you to set the s3_region.
|
123
|
+
s3_region may be nested in s3_credentials, and (if not nested in
|
124
|
+
s3_credentials) it may be a Proc.
|
26
125
|
|
27
|
-
4.3
|
126
|
+
4.3
|
28
127
|
|
29
|
-
|
30
|
-
|
31
|
-
* Fix GeometryParser regex for usage of '@>' flag
|
32
|
-
* `url` on a unpersisted record returns default_url
|
33
|
-
* spec deprecation warnings and failures
|
34
|
-
* README adjustments
|
128
|
+
See patch versions in v4.3 NEWS:
|
129
|
+
https://github.com/thoughtbot/paperclip/blob/v4.3/NEWS
|
35
130
|
|
36
|
-
4.3.0 (
|
131
|
+
4.3.0 (2015-06-18):
|
37
132
|
|
38
133
|
* Improvement: Update aws-sdk and cucumber gem versions.
|
39
134
|
* Improvement: Add `length` alias for `size` method in AbstractAdapter.
|
@@ -46,7 +141,7 @@
|
|
46
141
|
* Ruby Versioning: Drop support for 1.9.3 (EOL'ed)
|
47
142
|
* Rails Versioning: Drop support for 4.0.0 (EOL'ed)
|
48
143
|
|
49
|
-
4.2.4:
|
144
|
+
4.2.4 (2015-06-05):
|
50
145
|
|
51
146
|
* Rollback backwards incompatible change, allowing paperclip to run on
|
52
147
|
Ruby >= 1.9.2.
|