aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #36715 from peterzhu2118/azure-content-typeEileen M. Uchitelle2019-07-241-2/+2
|\ | | | | Add content_type to upload method for Azure
| * Add content_type to upload in AzurePeter Zhu2019-07-241-2/+2
| |
* | Merge pull request #36642 from wagenet/fix-disk-service-hostRafael França2019-07-231-1/+5
|\ \ | | | | | | Fix host for ActiveStorage DiskService
| * | Fix host for ActiveStorage DiskServicePeter Wagenet2019-07-091-1/+5
| |/ | | | | | | | | Previous behavior would only set host, which didn't work correctly if the default_url_options contained the protocol or the port.
* | Make Active Storage routes optionalGannon McGibbon2019-07-222-0/+2
| | | | | | | | Add configuration option to turn off drawing of Active Storage routes.
* | Preserve existing attachment assignment behavior for upgraded appsGeorge Claghorn2019-07-203-10/+27
|/ | | | | | | | | Assigning to a collection of attachments appends rather than replacing, as in 5.2. Existing 5.2 apps that rely on this behavior will no longer break when they're upgraded to 6.0. For apps generated on 6.0 or newer, assigning replaces the existing attachments in the collection. #attach should be used to add new attachments to the collection without removing existing ones. I expect that we'll deprecate the old behavior in 6.1. Closes #36374.
* Skip image analysis on ImageMagick errorGeorge Claghorn2019-05-301-0/+3
|
* Add :allow_nil option to delegate_missing_to; use in ActiveStorageMatt Tanous2019-05-231-1/+1
| | | | attachment
* Mirror direct uploadsGeorge Claghorn2019-05-223-6/+33
|
* S3: permit uploading files larger than 5 GBGeorge Claghorn2019-05-161-4/+28
| | | Use multipart uploads for files larger than 100 MB. Dynamically calculate part size based on total object size and maximum part count.
* Halve string allocations in S3 streaming and partial downloadsGeorge Claghorn2019-04-261-2/+2
| | | | See 19770d6.
* Start Rails 6.1 developmentRafael Mendonça França2019-04-241-2/+2
|
* Don't fail ImageAnalyzer on unsupported typesGuilherme Mansur2019-04-241-4/+11
| | | | | | | | | | Fix: #36065 The IamgeAnalyzer passes a image to ImageMagick without checking if the image is supported by ImageMagick. This patch checks that image is supported and if not logs an error and returns an empty hash instead of raising an error. This is the same error handling we do when we encounter a LoadError when mini_magick is not installed.
* Allow ActiveStorage to generate variants of BMP imagesYounes SERRAJ2019-04-211-0/+2
|
* Revert "Add ActiveStorage.service_configurations and ActiveStorage.service"George Claghorn2019-03-313-35/+29
| | | | This reverts commit 002684e36e813469c3585e193f0698784c88278b.
* Add ActiveStorage.service_configurations and ActiveStorage.serviceGeorge Claghorn2019-03-313-29/+35
| | | | | | * Allow plugins to access the global service and alternative service configs before ActiveStorage::Blob loads. * Make ActiveStorage.service_configurations the default second argument to ActiveStorage::Service.configure. Plugins that just want to use an alternative service defined in config/storage.yml needn't pass in the config themselves.
* Require railties for all Active Storage dependenciesGeorge Claghorn2019-03-301-0/+4
|
* Add ActiveStorage::Service#openGeorge Claghorn2019-03-284-21/+24
|
* GCS service: skip unnecessary bucket lookupsGeorge Claghorn2019-03-141-1/+1
|
* Merge tag 'v6.0.0.beta3'eileencodes2019-03-131-1/+1
|\ | | | | | | v6.0.0.beta3 release
| * Prep releaseeileencodes2019-03-111-1/+1
| | | | | | | | | | | | | | * Update RAILS_VERSION * Bundle * rake update_versions * rake changelog:header
* | Squish the deprecation messages across the codebasePrathamesh Sonpatki2019-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sample example -> Before: prathamesh@Prathameshs-MacBook-Pro-2 blog *$ rails server thin DEPRECATION WARNING: Passing the Rack server name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -u option instead. After: prathamesh@Prathameshs-MacBook-Pro-2 squish_app *$ rails server thin DEPRECATION WARNING: Passing the Rack server name as a regular argument is deprecated and will be removed in the next Rails version. Please, use the -u option instead.
* | Merge pull request #35412 from abhchand/correctly-load-blob-associationGeorge Claghorn2019-02-261-0/+1
|\ \ | |/ |/| Ensure that the `_blob` association is properly loaded when attaching `::One`
| * [ActiveStorage] Ensure that the `_blob` association is properly loaded when ↵Abhishek Chandrasekhar2019-02-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | attaching `::One` Consider a model with `One` and `Many` attachments configured: class User < ActiveRecord::Base has_one_attached :avatar has_many_attached :highlights end === One Attachment After attaching `One` attachment (`:avatar`), we can see that the associated `_blob` record (`:avatar_blob`) still returns as `nil`. user.avatar.attach(blob) user.avatar_attachment.present? => true user.avatar_blob.present? => false # Incorrect! This is a false negative. It happens because after the attachment and blob are built: 1. The record already has its `_blob` association loaded, as `nil` 2. the `::Attachment` is associated with the record but the `::Blob` only gets associated with the `::Attachment`, not the record itself In reality, the blob does in fact exist. We can verify this as follows: user.avatar.attach(blob) user.avatar_attachment.blob.present? => true # Blob does exist! The fix in this change is to simply assign the `::Blob` when assigning the `::Attachment`. After this fix is applied, we correctly observe: user.avatar.attach(blob) user.avatar_attachment.present? => true user.avatar_blob.present? => true # Woohoo! === Many Attachments We don't see this issue with `Many` attachments because the `_blob` association is already loaded as part of attaching more/newer blobs. user.highlights.attach(blob) user.highlights_attachments.any? => true user.highlights_blobs.any? => true
* | Preparing for 6.0.0.beta2 releaseRafael Mendonça França2019-02-251-1/+1
|/
* Add missing require to active_storage.rbEugene Kenny2019-02-201-0/+1
| | | | | | | Since b21f50d8ae36d9b50b673579e17bccbe55363b34, requiring active_storage on its own has failed with the following error: activestorage/lib/active_storage.rb:55:in `<module:ActiveStorage>': undefined method `minutes' for 5:Integer (NoMethodError)
* Delegated path_for to primary in the MirrorServiceAbhay Nikam2019-02-141-1/+1
|
* Allow configuring the Azure Storage service with extra client optionsgarytaylor2019-02-041-2/+2
|
* Merge pull request #35043 from simoleone/activestorage/s3/content-typeEileen M. Uchitelle2019-02-011-2/+2
|\ | | | | include the content type when uploading to S3
| * include the content type when uploading to S3Simo Leone2019-01-241-2/+2
| |
* | ActiveStorage typo fix.alkesh262019-01-311-1/+1
| |
* | Fix usage documentation in VideoAnalyzerCarlos Ramirez III2019-01-281-1/+1
|/ | | The code snippet within the usage documentation comment used the wrong object namespace for the ActiveStorage::Analyzer::VideoAnalyzer
* Preparing for 6.0.0.beta1 releaseRafael Mendonça França2019-01-181-1/+1
|
* Add foreign key to active_storage_attachments for `blob_id` via new migrationbogdanvlviv2019-01-161-0/+7
| | | | | | | | | | | | | | | | | | We need this in order to be able to add this migration for users that use ActiveStorage during update their apps from Rails 5.2 to Rails 6.0. Related to #33405 `rake app:update` should update active_storage `rake app:update` should execute `rake active_storage:update` if it is used in the app that is being updated. It will add new active_storage's migrations to users' apps during update Rails. Context https://github.com/rails/rails/pull/33405#discussion_r204239399 Also, see a related discussion in the Campfire: https://3.basecamp.com/3076981/buckets/24956/chats/12416418@1236713081
* Permit sending Active Storage purge and analysis jobs to separate queuesGeorge Claghorn2019-01-012-2/+16
|
* Bump license years for 2019Arun Agrawal2018-12-311-1/+1
|
* Permit generating variants of TIFF imagesLuciano Sousa2018-12-301-0/+2
|
* Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-214-68/+44
| | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* Fix `ArgumentError` when uploading to amazon s3Hiroki Sanpei2018-11-281-1/+1
|
* Prevent content type and disposition bypass in storage service URLsRosa Gutierrez2018-11-277-22/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Force content-type to binary on service urls for relevant content types We have a list of content types that must be forcibly served as binary, but in practice this only means to serve them as attachment always. We should also set the Content-Type to the configured binary type. As a bonus: add text/cache-manifest to the list of content types to be served as binary by default. * Store content-disposition and content-type in GCS Forcing these in the service_url when serving the file works fine for S3 and Azure, since these services include params in the signature. However, GCS specifically excludes response-content-disposition and response-content-type from the signature, which means an attacker can modify these and have files that should be served as text/plain attachments served as inline HTML for example. This makes our attempt to force specific files to be served as binary and as attachment can be easily bypassed. The only way this can be forced in GCS is by storing content-disposition and content-type in the object metadata. * Update GCS object metadata after identifying blob In some cases we create the blob and upload the data before identifying the content-type, which means we can't store that in GCS right when uploading. In these, after creating the attachment, we enqueue a job to identify the blob, and set the content-type. In other cases, files are uploaded to the storage service via direct upload link. We create the blob before the direct upload, which happens independently from the blob creation itself. We then mark the blob as identified, but we have already the content-type we need without having put it in the service. In these two cases, then, we need to update the metadata in the GCS service. * Include content-type and disposition in the verified key for disk service This prevents an attacker from modifying these params in the service signed URL, which is particularly important when we want to force them to have specific values for security reasons. * Allow only a list of specific content types to be served inline This is different from the content types that must be served as binary in the sense that any content type not in this list will be always served as attachment but with its original content type. Only types in this list are allowed to be served either inline or as attachment. Apart from forcing this in the service URL, for GCS we need to store the disposition in the metadata. Fix CVE-2018-16477.
* Add progressive JPG to default variable content typesMaurice Kühlborn2018-11-211-0/+1
|
* Merge pull request #33829 from mtsmfm/encode-filenameKasper Timm Hansen2018-09-231-1/+4
|\ | | | | Encode Content-Disposition filenames on send_data and send_file
| * Encode Content-Disposition filenames on send_data and send_fileFumiaki MATSUSHIMA2018-09-131-1/+4
| |
* | Configure Active Storage route prefixChris Bisnett2018-09-142-0/+2
|/ | | | | | | | | | | Applications can configure the route prefix prepended to the Active Storage routes. By default this maintains the previous prefix `/rails/active_storage` but supports custom prefixes. Before this change the route for serving blobs is fixed to `/rails/active_storage/blobs/:signed_id/*filename`. After this change it's possible to configure the route to something like `/files/blobs/:signed_id/*filename`.
* Handle only specifically relevant Azure HTTPErrorsCameron Bothner2018-08-231-5/+7
| | | | | | | | | The Azure gem uses `Azure::Core::Http::HTTPError` for everything: checksum mismatch, missing object, network unavailable, and many more. (https://www.rubydoc.info/github/yaxia/azure-storage-ruby/Azure/Core/Http/HTTPError). Rescuing that class obscures all sorts of configuration errors. We should check the type of error in those rescue blocks, and reraise when needed.
* Revert "Merge pull request #33667 from ↵George Claghorn2018-08-231-13/+7
| | | | | | | cbothner/azure-service-swallowing-all-errors" This reverts commit b204d167c5cfebd59f771d406178e371811ac43a, reversing changes made to de6a200f82a3de399fa685d583503bc88dbc5e9f.
* Handle only specifically relevant Azure HTTPErrorsCameron Bothner2018-08-231-7/+13
| | | | | | | | | The Azure gem uses `Azure::Core::Http::HTTPError` for everything: checksum mismatch, missing object, network unavailable, and many more. (https://www.rubydoc.info/github/yaxia/azure-storage-ruby/Azure/Core/Http/HTTPError). Rescuing that class obscures all sorts of configuration errors. We should check the type of error in those rescue blocks, and reraise when needed.
* Translate service-specific missing object exceptions into a generic oneCameron Bothner2018-08-215-18/+72
| | | | | | | | | `ActiveStorage::Blob#download` and `ActiveStorage::Blob#open` raise `ActiveStorage::FileNotFoundError` when the corresponding file is missing from the storage service. Services translate service-specific missing object exceptions (e.g. `Google::Cloud::NotFoundError` for the GCS service and `Errno::ENOENT` for the disk service) into `ActiveStorage::FileNotFoundError`.
* Document all Active Storage error classes [ci skip]George Claghorn2018-08-101-0/+8
|
* Add a generic base class for Active Storage exceptionsGeorge Claghorn2018-08-101-4/+7
| | | | | | Closes #33292. [Andrei Makarov & George Claghorn]