aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage
diff options
context:
space:
mode:
Diffstat (limited to 'activestorage')
-rw-r--r--activestorage/CHANGELOG.md178
-rw-r--r--activestorage/lib/active_storage/analyzer/image_analyzer.rb15
-rw-r--r--activestorage/lib/active_storage/gem_version.rb4
-rw-r--r--activestorage/lib/active_storage/service/s3_service.rb4
-rw-r--r--activestorage/package.json2
-rw-r--r--activestorage/test/analyzer/image_analyzer_test.rb8
6 files changed, 25 insertions, 186 deletions
diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md
index d524ecf7d6..957591ec0a 100644
--- a/activestorage/CHANGELOG.md
+++ b/activestorage/CHANGELOG.md
@@ -1,179 +1,3 @@
-* Permit generating variants of BMP images.
- *Younes Serraj*
-## Rails 6.0.0.beta3 (March 11, 2019) ##
-
-* No changes.
-
-
-## Rails 6.0.0.beta2 (February 25, 2019) ##
-
-* No changes.
-
-
-## Rails 6.0.0.beta1 (January 18, 2019) ##
-
-* [Rename npm package](https://github.com/rails/rails/pull/34905) from
- [`activestorage`](https://www.npmjs.com/package/activestorage) to
- [`@rails/activestorage`](https://www.npmjs.com/package/@rails/activestorage).
-
- *Javan Makhmali*
-
-* Replace `config.active_storage.queue` with two options that indicate which
- queues analysis and purge jobs should use, respectively:
-
- * `config.active_storage.queues.analysis`
- * `config.active_storage.queues.purge`
-
- `config.active_storage.queue` is preferred over the new options when it's
- set, but it is deprecated and will be removed in Rails 6.1.
-
- *George Claghorn*
-
-* Permit generating variants of TIFF images.
-
- *Luciano Sousa*
-
-* Use base36 (all lowercase) for all new Blob keys to prevent
- collisions and undefined behavior with case-insensitive filesystems and
- database indices.
-
- *Julik Tarkhanov*
-
-* It doesn’t include an `X-CSRF-Token` header if a meta tag is not found on
- the page. It previously included one with a value of `undefined`.
-
- *Cameron Bothner*
-
-* Fix `ArgumentError` when uploading to amazon s3
-
- *Hiroki Sanpei*
-
-* Add progressive JPG to default list of variable content types
-
- *Maurice Kühlborn*
-
-* Add `ActiveStorage.routes_prefix` for configuring generated routes.
-
- *Chris Bisnett*
-
-* `ActiveStorage::Service::AzureStorageService` only handles specifically
- relevant types of `Azure::Core::Http::HTTPError`. It previously obscured
- other types of `HTTPError`, which is the azure-storage gem’s catch-all
- exception class.
-
- *Cameron Bothner*
-
-* `ActiveStorage::DiskController#show` generates a 404 Not Found response when
- the requested file is missing from the disk service. It previously raised
- `Errno::ENOENT`.
-
- *Cameron Bothner*
-
-* `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`.
-
- *Cameron Bothner*
-
-* Added the `ActiveStorage::SetCurrent` concern for custom Active Storage
- controllers that can't inherit from `ActiveStorage::BaseController`.
-
- *George Claghorn*
-
-* Active Storage error classes like `ActiveStorage::IntegrityError` and
- `ActiveStorage::UnrepresentableError` now inherit from `ActiveStorage::Error`
- instead of `StandardError`. This permits rescuing `ActiveStorage::Error` to
- handle all Active Storage errors.
-
- *Andrei Makarov*, *George Claghorn*
-
-* Uploaded files assigned to a record are persisted to storage when the record
- is saved instead of immediately.
-
- In Rails 5.2, the following causes an uploaded file in `params[:avatar]` to
- be stored:
-
- ```ruby
- @user.avatar = params[:avatar]
- ```
-
- In Rails 6, the uploaded file is stored when `@user` is successfully saved.
-
- *George Claghorn*
-
-* Add the ability to reflect on defined attachments using the existing
- ActiveRecord reflection mechanism.
-
- *Kevin Deisz*
-
-* Variant arguments of `false` or `nil` will no longer be passed to the
- processor. For example, the following will not have the monochrome
- variation applied:
-
- ```ruby
- avatar.variant(monochrome: false)
- ```
-
- *Jacob Smith*
-
-* Generated attachment getter and setter methods are created
- within the model's `GeneratedAssociationMethods` module to
- allow overriding and composition using `super`.
-
- *Josh Susser*, *Jamon Douglas*
-
-* Add `ActiveStorage::Blob#open`, which downloads a blob to a tempfile on disk
- and yields the tempfile. Deprecate `ActiveStorage::Downloading`.
-
- *David Robertson*, *George Claghorn*
-
-* Pass in `identify: false` as an argument when providing a `content_type` for
- `ActiveStorage::Attached::{One,Many}#attach` to bypass automatic content
- type inference. For example:
-
- ```ruby
- @message.image.attach(
- io: File.open('/path/to/file'),
- filename: 'file.pdf',
- content_type: 'application/pdf',
- identify: false
- )
- ```
-
- *Ryan Davidson*
-
-* The Google Cloud Storage service properly supports streaming downloads.
- It now requires version 1.11 or newer of the google-cloud-storage gem.
-
- *George Claghorn*
-
-* Use the [ImageProcessing](https://github.com/janko-m/image_processing) gem
- for Active Storage variants, and deprecate the MiniMagick backend.
-
- This means that variants are now automatically oriented if the original
- image was rotated. Also, in addition to the existing ImageMagick
- operations, variants can now use `:resize_to_fit`, `:resize_to_fill`, and
- other ImageProcessing macros. These are now recommended over raw `:resize`,
- as they also sharpen the thumbnail after resizing.
-
- The ImageProcessing gem also comes with a backend implemented on
- [libvips](http://jcupitt.github.io/libvips/), an alternative to
- ImageMagick which has significantly better performance than
- ImageMagick in most cases, both in terms of speed and memory usage. In
- Active Storage it's now possible to switch to the libvips backend by
- changing `Rails.application.config.active_storage.variant_processor` to
- `:vips`.
-
- *Janko Marohnić*
-
-* Rails 6 requires Ruby 2.5.0 or newer.
-
- *Jeremy Daer*, *Kasper Timm Hansen*
-
-
-Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activestorage/CHANGELOG.md) for previous changes.
+Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activestorage/CHANGELOG.md) for previous changes.
diff --git a/activestorage/lib/active_storage/analyzer/image_analyzer.rb b/activestorage/lib/active_storage/analyzer/image_analyzer.rb
index 3b39de91be..c8bc8fe953 100644
--- a/activestorage/lib/active_storage/analyzer/image_analyzer.rb
+++ b/activestorage/lib/active_storage/analyzer/image_analyzer.rb
@@ -25,17 +25,24 @@ module ActiveStorage
{ width: image.width, height: image.height }
end
end
- rescue LoadError
- logger.info "Skipping image analysis because the mini_magick gem isn't installed"
- {}
end
private
def read_image
download_blob_to_tempfile do |file|
require "mini_magick"
- yield MiniMagick::Image.new(file.path)
+ image = MiniMagick::Image.new(file.path)
+
+ if image.valid?
+ yield image
+ else
+ logger.info "Skipping image analysis because ImageMagick doesn't support the file"
+ {}
+ end
end
+ rescue LoadError
+ logger.info "Skipping image analysis because the mini_magick gem isn't installed"
+ {}
end
def rotated_image?(image)
diff --git a/activestorage/lib/active_storage/gem_version.rb b/activestorage/lib/active_storage/gem_version.rb
index d8f8577cc3..5ef5d09f28 100644
--- a/activestorage/lib/active_storage/gem_version.rb
+++ b/activestorage/lib/active_storage/gem_version.rb
@@ -8,9 +8,9 @@ module ActiveStorage
module VERSION
MAJOR = 6
- MINOR = 0
+ MINOR = 1
TINY = 0
- PRE = "beta3"
+ PRE = "alpha"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
end
diff --git a/activestorage/lib/active_storage/service/s3_service.rb b/activestorage/lib/active_storage/service/s3_service.rb
index bf94f3f49e..c7e4ec96a2 100644
--- a/activestorage/lib/active_storage/service/s3_service.rb
+++ b/activestorage/lib/active_storage/service/s3_service.rb
@@ -40,7 +40,7 @@ module ActiveStorage
def download_chunk(key, range)
instrument :download_chunk, key: key, range: range do
- object_for(key).get(range: "bytes=#{range.begin}-#{range.exclude_end? ? range.end - 1 : range.end}").body.read.force_encoding(Encoding::BINARY)
+ object_for(key).get(range: "bytes=#{range.begin}-#{range.exclude_end? ? range.end - 1 : range.end}").body.string.force_encoding(Encoding::BINARY)
rescue Aws::S3::Errors::NoSuchKey
raise ActiveStorage::FileNotFoundError
end
@@ -108,7 +108,7 @@ module ActiveStorage
raise ActiveStorage::FileNotFoundError unless object.exists?
while offset < object.content_length
- yield object.get(range: "bytes=#{offset}-#{offset + chunk_size - 1}").body.read.force_encoding(Encoding::BINARY)
+ yield object.get(range: "bytes=#{offset}-#{offset + chunk_size - 1}").body.string.force_encoding(Encoding::BINARY)
offset += chunk_size
end
end
diff --git a/activestorage/package.json b/activestorage/package.json
index c363acebde..39a1ea1383 100644
--- a/activestorage/package.json
+++ b/activestorage/package.json
@@ -1,6 +1,6 @@
{
"name": "@rails/activestorage",
- "version": "6.0.0-beta3",
+ "version": "6.1.0-alpha",
"description": "Attach cloud and local files in Rails applications",
"main": "app/assets/javascripts/activestorage.js",
"files": [
diff --git a/activestorage/test/analyzer/image_analyzer_test.rb b/activestorage/test/analyzer/image_analyzer_test.rb
index 55bb5e7280..73438c15ab 100644
--- a/activestorage/test/analyzer/image_analyzer_test.rb
+++ b/activestorage/test/analyzer/image_analyzer_test.rb
@@ -29,4 +29,12 @@ class ActiveStorage::Analyzer::ImageAnalyzerTest < ActiveSupport::TestCase
assert_equal 792, metadata[:width]
assert_equal 584, metadata[:height]
end
+
+ test "analyzing an unsupported image type" do
+ blob = create_blob(data: "bad", filename: "bad_file.bad", content_type: "image/bad_type")
+ metadata = extract_metadata_from(blob)
+
+ assert_nil metadata[:width]
+ assert_nil metadata[:heigh]
+ end
end