CHANGELOG.md 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
*   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*

11 12 13 14
*   Make services aware of configuration names.

    *Gannon McGibbon*

K
Kyle Ribordy 已提交
15 16 17 18
*   The `Content-Type` header is set on image variants when they're uploaded to third-party storage services.

    *Kyle Ribordy*

19 20 21 22 23 24 25 26 27 28 29 30 31 32
*   Allow storage services to be configured per attachment

    ```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*

33 34 35 36 37 38 39 40 41 42 43
*   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*

44 45 46
*   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
47
    corruption by uploading to a key on the storage service which happened to
48 49 50 51 52 53 54 55
    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*

56 57 58 59
*   Set content disposition in direct upload using `filename` and `disposition` parameters to `ActiveStorage::Service#headers_for_direct_upload`.

    *Peter Zhu*

60 61 62 63 64
*   Allow record to be optionally passed to blob finders to make sharding
    easier.

    *Gannon McGibbon*

65 66 67 68
*   Switch from `azure-storage` gem to `azure-storage-blob` gem for Azure service.

    *Peter Zhu*

69 70 71 72
*   Add `config.active_storage.draw_routes` to disable Active Storage routes.

    *Gannon McGibbon*

73
*   Image analysis is skipped if ImageMagick returns an error.
74

75 76 77 78
    `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.
79

80
    *George Claghorn*
81

82
*   Method calls on singular attachments return `nil` when no file is attached.
83

84 85
    Previously, assuming the following User model, `user.avatar.filename` would
    raise a `Module::DelegationError` if no avatar was attached:
86

87 88 89 90 91
    ```ruby
    class User < ApplicationRecord
      has_one_attached :avatar
    end
    ```
92

93
    They now return `nil`.
94

95
    *Matthew Tanous*
96

97
*   The mirror service supports direct uploads.
G
George Claghorn 已提交
98

99 100 101
    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.
G
George Claghorn 已提交
102

103 104
    Configure the queue used to process mirroring jobs by setting
    `config.active_storage.queues.mirror`. The default is `:active_storage_mirror`.
G
George Claghorn 已提交
105

106
    *George Claghorn*
G
George Claghorn 已提交
107

108
*   The S3 service now permits uploading files larger than 5 gigabytes.
109

110 111 112
    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.
113

114 115 116
    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:
117

118 119 120 121 122 123 124 125 126 127 128 129
    ```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*
130

131

132
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activestorage/CHANGELOG.md) for previous changes.