2020-07-20 20:44:32 -04:00
|
|
|
* Touch parent model when an attachment is purged.
|
|
|
|
|
|
|
|
*Víctor Pérez Rodríguez*
|
|
|
|
|
2020-05-11 16:21:58 -04:00
|
|
|
* Files can now be served by proxying them from the underlying storage service
|
|
|
|
instead of redirecting to a signed service URL. Use the
|
|
|
|
`rails_storage_proxy_path` and `_url` helpers to proxy an attached file:
|
|
|
|
|
|
|
|
```erb
|
|
|
|
<%= image_tag rails_storage_proxy_path(@user.avatar) %>
|
|
|
|
```
|
|
|
|
|
|
|
|
To proxy by default, set `config.active_storage.resolve_model_to_route`:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
# Proxy attached files instead.
|
|
|
|
config.active_storage.resolve_model_to_route = :rails_storage_proxy
|
|
|
|
```
|
|
|
|
|
|
|
|
```erb
|
|
|
|
<%= image_tag @user.avatar %>
|
|
|
|
```
|
|
|
|
|
|
|
|
To redirect to a signed service URL when the default file serving strategy
|
|
|
|
is set to proxying, use the `rails_storage_redirect_path` and `_url` helpers:
|
|
|
|
|
|
|
|
```erb
|
|
|
|
<%= image_tag rails_storage_redirect_path(@user.avatar) %>
|
|
|
|
```
|
|
|
|
|
|
|
|
*Jonathan Fleckenstein*
|
|
|
|
|
2020-04-19 15:59:39 -04:00
|
|
|
* Add `config.active_storage.web_image_content_types` to allow applications
|
|
|
|
to add content types (like `image/webp`) in which variants can be processed,
|
|
|
|
instead of letting those images be converted to the fallback PNG format.
|
|
|
|
|
|
|
|
*Jeroen van Haperen*
|
|
|
|
|
2020-03-09 08:08:53 -04:00
|
|
|
* Add support for creating variants of `WebP` images out of the box.
|
|
|
|
|
|
|
|
*Dino Maric*
|
2020-04-15 08:23:24 -04:00
|
|
|
|
2020-01-16 14:14:28 -05:00
|
|
|
* Only enqueue analysis jobs for blobs with non-null analyzer classes.
|
|
|
|
|
|
|
|
*Gannon McGibbon*
|
|
|
|
|
2019-12-20 15:06:03 -05:00
|
|
|
* Previews are created on the same service as the original blob.
|
|
|
|
|
|
|
|
*Peter Zhu*
|
|
|
|
|
2019-12-06 14:26:00 -05:00
|
|
|
* Remove unused `disposition` and `content_type` query parameters for `DiskService`.
|
|
|
|
|
|
|
|
*Peter Zhu*
|
|
|
|
|
2019-12-05 22:31:23 -05:00
|
|
|
* Use `DiskController` for both public and private files.
|
|
|
|
|
|
|
|
`DiskController` is able to handle multiple services by adding a
|
|
|
|
`service_name` field in the generated URL in `DiskService`.
|
|
|
|
|
|
|
|
*Peter Zhu*
|
|
|
|
|
2019-12-05 22:21:24 -05:00
|
|
|
* Variants are tracked in the database to avoid existence checks in the storage service.
|
|
|
|
|
|
|
|
*George Claghorn*
|
|
|
|
|
2019-12-02 11:34:01 -05:00
|
|
|
* Deprecate `service_url` methods in favour of `url`.
|
|
|
|
|
|
|
|
Deprecate `Variant#service_url` and `Preview#service_url` to instead use
|
|
|
|
`#url` method to be consistent with `Blob`.
|
|
|
|
|
|
|
|
*Peter Zhu*
|
|
|
|
|
2019-07-22 11:46:02 -04:00
|
|
|
* Permanent URLs for public storage blobs.
|
|
|
|
|
|
|
|
Services can be configured in `config/storage.yml` with a new key
|
|
|
|
`public: true | false` to indicate whether a service holds public
|
|
|
|
blobs or private blobs. Public services will always return a permanent URL.
|
|
|
|
|
|
|
|
Deprecates `Blob#service_url` in favor of `Blob#url`.
|
|
|
|
|
|
|
|
*Peter Zhu*
|
|
|
|
|
2019-10-01 16:54:37 -04:00
|
|
|
* Make services aware of configuration names.
|
|
|
|
|
|
|
|
*Gannon McGibbon*
|
|
|
|
|
2019-09-17 00:08:22 -04:00
|
|
|
* The `Content-Type` header is set on image variants when they're uploaded to third-party storage services.
|
|
|
|
|
|
|
|
*Kyle Ribordy*
|
|
|
|
|
2019-11-23 19:20:00 -05:00
|
|
|
* Allow storage services to be configured per attachment.
|
2019-01-14 14:56:35 -05:00
|
|
|
|
|
|
|
```ruby
|
|
|
|
class User < ActiveRecord::Base
|
|
|
|
has_one_attached :avatar, service: :s3
|
|
|
|
end
|
|
|
|
|
|
|
|
class Gallery < ActiveRecord::Base
|
|
|
|
has_many_attached :photos, service: :s3
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
*Dmitry Tsepelev*
|
|
|
|
|
2019-09-29 20:02:57 -04:00
|
|
|
* You can optionally provide a custom blob key when attaching a new file:
|
|
|
|
|
|
|
|
```ruby
|
|
|
|
user.avatar.attach key: "avatars/#{user.id}.jpg",
|
|
|
|
io: io, content_type: "image/jpeg", filename: "avatar.jpg"
|
|
|
|
```
|
|
|
|
|
|
|
|
Active Storage will store the blob's data on the configured service at the provided key.
|
|
|
|
|
|
|
|
*George Claghorn*
|
|
|
|
|
2019-09-24 07:32:59 -04:00
|
|
|
* Replace `Blob.create_after_upload!` with `Blob.create_and_upload!` and deprecate the former.
|
|
|
|
|
|
|
|
`create_after_upload!` has been removed since it could lead to data
|
2019-09-24 08:14:30 -04:00
|
|
|
corruption by uploading to a key on the storage service which happened to
|
2019-09-24 07:32:59 -04:00
|
|
|
be already taken. Creating the record would then correctly raise a
|
|
|
|
database uniqueness exception but the stored object would already have
|
|
|
|
overwritten another. `create_and_upload!` swaps the order of operations
|
|
|
|
so that the key gets reserved up-front or the uniqueness error gets raised,
|
|
|
|
before the upload to a key takes place.
|
|
|
|
|
|
|
|
*Julik Tarkhanov*
|
|
|
|
|
2019-07-28 16:13:22 -04:00
|
|
|
* Set content disposition in direct upload using `filename` and `disposition` parameters to `ActiveStorage::Service#headers_for_direct_upload`.
|
|
|
|
|
|
|
|
*Peter Zhu*
|
|
|
|
|
2019-07-19 18:32:20 -04:00
|
|
|
* Allow record to be optionally passed to blob finders to make sharding
|
|
|
|
easier.
|
|
|
|
|
|
|
|
*Gannon McGibbon*
|
|
|
|
|
2019-08-06 12:25:39 -04:00
|
|
|
* Switch from `azure-storage` gem to `azure-storage-blob` gem for Azure service.
|
|
|
|
|
|
|
|
*Peter Zhu*
|
|
|
|
|
2019-07-12 15:30:28 -04:00
|
|
|
* Add `config.active_storage.draw_routes` to disable Active Storage routes.
|
|
|
|
|
|
|
|
*Gannon McGibbon*
|
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
* Image analysis is skipped if ImageMagick returns an error.
|
2019-05-30 22:33:29 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
`ActiveStorage::Analyzer::ImageAnalyzer#metadata` would previously raise a
|
|
|
|
`MiniMagick::Error`, which caused persistent `ActiveStorage::AnalyzeJob`
|
|
|
|
failures. It now logs the error and returns `{}`, resulting in no metadata
|
|
|
|
being added to the offending image blob.
|
2019-05-30 22:33:29 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
*George Claghorn*
|
2019-05-30 22:33:29 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
* Method calls on singular attachments return `nil` when no file is attached.
|
2018-07-25 17:04:34 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
Previously, assuming the following User model, `user.avatar.filename` would
|
|
|
|
raise a `Module::DelegationError` if no avatar was attached:
|
2018-07-25 17:04:34 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
```ruby
|
|
|
|
class User < ApplicationRecord
|
|
|
|
has_one_attached :avatar
|
|
|
|
end
|
|
|
|
```
|
2019-05-30 22:33:29 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
They now return `nil`.
|
2018-07-25 17:04:34 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
*Matthew Tanous*
|
2018-07-25 17:04:34 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
* The mirror service supports direct uploads.
|
2019-05-22 15:07:35 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
New files are directly uploaded to the primary service. When a
|
|
|
|
directly-uploaded file is attached to a record, a background job is enqueued
|
|
|
|
to copy it to each secondary service.
|
2019-05-22 15:07:35 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
Configure the queue used to process mirroring jobs by setting
|
|
|
|
`config.active_storage.queues.mirror`. The default is `:active_storage_mirror`.
|
2019-05-22 15:07:35 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
*George Claghorn*
|
2019-05-22 15:07:35 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
* The S3 service now permits uploading files larger than 5 gigabytes.
|
2019-04-24 14:19:15 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
When uploading a file greater than 100 megabytes in size, the service
|
|
|
|
transparently switches to [multipart uploads](https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html)
|
|
|
|
using a part size computed from the file's total size and S3's part count limit.
|
2019-05-16 10:58:33 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
No application changes are necessary to take advantage of this feature. You
|
|
|
|
can customize the default 100 MB multipart upload threshold in your S3
|
|
|
|
service's configuration:
|
2019-05-16 10:58:33 -04:00
|
|
|
|
2019-06-04 16:47:33 -04:00
|
|
|
```yaml
|
|
|
|
production:
|
|
|
|
service: s3
|
|
|
|
access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
|
|
|
secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
|
|
|
region: us-east-1
|
|
|
|
bucket: my-bucket
|
|
|
|
upload:
|
|
|
|
multipart_threshold: <%= 250.megabytes %>
|
|
|
|
```
|
|
|
|
|
|
|
|
*George Claghorn*
|
2019-05-16 10:58:33 -04:00
|
|
|
|
2019-04-23 16:11:10 -04:00
|
|
|
|
2019-04-24 15:57:14 -04:00
|
|
|
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activestorage/CHANGELOG.md) for previous changes.
|