Commit Graph

296 Commits

Author SHA1 Message Date
Andrew White
d7b7276104 Remove backported CHANGELOG entry [ci skip] 2018-03-19 15:30:23 +00:00
Brian Knight
c1600009b2 Allow full use of the AWS S3 SDK authentication options (#32270)
If an explicit AWS key pair and/or region is not provided in
config/storage.yml, attempt to use environment variables, shared
credentials, or IAM role credentials. Order of precedence is
determined by the AWS SDK[1].

[1]: https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html
2018-03-19 15:25:40 +00:00
Rafael Mendonça França
ba0ae542ca
Remove changelog header for unreleased version
We only add the header when releasing to avoid some conflicts.

[ci skip]
2018-03-13 15:20:57 -04:00
George Claghorn
fcbe17137d Fix Azure signed URL generation with newer client lib 2018-03-12 23:14:20 -04:00
George Claghorn
0443cb130c Update ASt test services config 2018-03-12 19:00:54 -04:00
Andrew White
309bb6c4d0 Remove path config option from Azure service
The Active Storage service for Azure Storage has an option called `path`
that is ambiguous in meaning. It needs to be set to the primary blob
storage endpoint but that can be determined from the blobs client anyway.

To simplify the configuration this commit removes the `path` option and
gets the endpoint from the blobs client instead.

Closes #32225.
2018-03-12 17:39:58 +00:00
Terence Lee
0b717c2045 Provide an alternative PDF previewer based on Poppler
mutool is licensed under the Affero GPL, which has strict distribution requirements.

Poppler is licensed under the more liberal GPL, making it a good alternative for those who can't use mutool.
2018-03-06 13:33:33 -05:00
George Claghorn
060ed201e4 Update test to reflect GCS direct upload header change 2018-03-06 13:09:22 -05:00
Nicholas Shirley
f9a5839083 Allow selectively purging attached blobs 2018-03-06 13:03:02 -05:00
George Claghorn
40d3fa5dfe Remove blank Content-Type from GCS direct upload headers
Since we started clearing the client-side blob's type in e0867b3, we no longer need to set a blank Content-Type header before issuing the direct upload request. Fixes that Safari 9 would combine the blank Content-Type header with the blank blob type to produce a Content-Type header containing a single comma, invalidating the request.
2018-03-06 10:05:50 -05:00
George Claghorn
9cc88043e7 Fix purging dependent blobs when attachments aren't loaded 2018-03-05 17:01:31 -05:00
George Claghorn
8228d12a43 Delete dependent attachments with record
[Matt Jones & George Claghorn]
2018-03-05 15:57:52 -05:00
George Claghorn
e83575ff53 Correct the ActiveStorage::Service#download_chunk docs [ci skip] 2018-03-05 13:27:14 -05:00
George Claghorn
ccac681122 Generate root-relative paths in Active Storage disk service URL methods
Fixes #32129.
2018-03-05 11:54:43 -05:00
George Claghorn
7e658588fa Handle another case where a blob might be erroneously purged 2018-03-04 18:54:31 -05:00
George Claghorn
4ed4c75c1f Avoid purging attached blob when replacing it with itself 2018-03-04 17:56:45 -05:00
Kasper Timm Hansen
0f302b8970
Merge Previews/Variants controller into one Representations controller.
Since ActiveStorage::Blob::Representable unifies the idea of previews and
variants under one roof as representation, we may as well have the
controllers follow suit.

Thus ActiveStorage::RepresenationsController enters the fray. I've copied
the old tests for both previews and variants and unified those as well.
2018-03-03 21:36:43 +01:00
yuuji.yaginuma
acbcec8ea8 Deprecate active_support/core_ext/hash/compact
Ruby 2.4+ provides `Hash#compact` and `Hash#compact!` natively,
so `active_support/core_ext/hash/compact` is no longer necessary.
2018-03-02 16:40:55 -08:00
George Claghorn
f008562dd3 Rebuild activestorage.js 2018-02-28 14:10:51 -05:00
George Claghorn
5a66a14226 Handle file checksumming errors 2018-02-28 14:04:36 -05:00
George Claghorn
e0867b3672 Clear Blob's type before sending it
Prevent older versions of Chrome from appending a Content-Type header containing the Blob type, rendering the request invalid if we intend not to provide a Content-Type. This behavior was observed in Chrome 58.
2018-02-26 17:20:55 -05:00
George Claghorn
87de79e9cc Update test to reflect direct upload header changes 2018-02-26 13:56:54 -05:00
George Claghorn
8a79d04e4d Avoid specifying content types for direct uploads to Google Cloud Storage
Fix customizing the download Content-Type for a directly-uploaded blob via a signed URL. See e8286ee.
2018-02-26 12:00:24 -05:00
bogdanvlviv
ae3e241b57
Remove changelogs for Rails 6.0 since they were backported to 5-2-stable
Remove railties' changelog added by 7340596de45dc4c0f62a287b6acc4e71d8ee6c60
since it was backported to `5-2-stable` via ac99916fcf7bf27bb1519d4f7387c6b4c5f0463d

Remove activesupport's changelog added by 1077ae96b34b5a1dfbf10ee0c40b1ceb1eb6b30b
since it was backported to `5-2-stable` via a2b97e4ffef971607a1be8fc7909f099b6840f36

Remove activesupport's changelog added by 0d41a76d0c693000005d79456dee7f9299f5e8d4
since it was backported to `5-2-stable` via cdce6a709e1cbc98fff009effc3b1b3ce4c7e8db

Remove activestorage's changelog added by d57c52a385eb57c6ce8c6d124ab5e186f931d142
since it was backported to `5-2-stable` via 5292cdf59a2052c453d6016c69b90b790cbf2547

Follow up c113bdc9d0c2cffd535ca97aff85c4bdc46b11f6
2018-02-26 00:10:57 +02:00
Eugene Kenny
eb834811dc Use lazy load hook to configure ActiveStorage::Blob
`to_prepare` callbacks are run during initialization; using one here
meant that `ActiveStorage::Blob` would be loaded when the app boots,
which would in turn load `ActiveRecord::Base`.

By using a lazy load hook to configure `ActiveStorage::Blob` instead,
we can avoid loading `ActiveRecord::Base` unnecessarily.
2018-02-25 00:54:27 +00:00
George Claghorn
3915a470d2 Support varying ICO files
Closes #32096.
2018-02-24 15:27:57 -05:00
Andrew White
7dce840dee Allow S3 tests against buckets in other regions
Only us-east-1 gives URLs like bucket.s3.amazonaws.com whereas other
regions have URLs like s3-eu-west-1.amazonaws.com/ubxd-rails
2018-02-21 12:06:25 +00:00
George Claghorn
9794e85351 Hoist update for clarity 2018-02-20 18:08:14 -05:00
George Claghorn
d94db07774 Undocument ActiveStorage::Identification 2018-02-20 18:03:44 -05:00
George Claghorn
9208a52220 Correct Range header syntax 2018-02-20 14:45:54 -05:00
Jeremy Daer
d4eb0dc89e Rails 6 requires Ruby 2.4.1+
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.

References #32028
2018-02-17 15:34:57 -08:00
bogdanvlviv
0f98954a83
Clean up and consolidate .gitignores
* Global ignores at toplevel .gitignore
* Component-specific ignores in each toplevel directory
* Remove `actionview/test/tmp/.keep` for JRuby

```
rm actionview/test/tmp/ -fr
cd actionview/
bundle exec jruby -Itest test/template/digestor_test.rb
```

Related to #11743, #30392.

Closes #29978.
2018-02-17 14:26:19 -08:00
Rafael Mendonça França
0ea8e7db1a Remove support to Ruby 2.2
Rails 6 will only support Ruby >= 2.3.
2018-02-16 18:52:10 -05:00
Eugene Kenny
1e55ee5a28 Use require_dependency inside Active Storage
Active Storage is an engine which means its models, jobs and controllers
are autoloaded by Rails rather than Ruby. Unfortunately this means it's
subject to the same gotchas as applications, including this one:

http://guides.rubyonrails.org/v5.1.4/autoloading_and_reloading_constants.html#when-constants-aren-t-missed-qualified-references

On Ruby < 2.5, constants nested under classes can't be autoloaded by
Rails if a top level constant already exists with the same name.

To avoid clashing with constants defined in users' applications or gems,
we can use `require_dependency` to ensure that the nested constants are
loaded before they're used.
2018-02-14 23:15:12 +00:00
George Claghorn
c476969b44 Document MuPDF version requirement 2018-02-13 10:47:39 -05:00
fatkodima
0c463f50ea Add ActiveStorage::Blob.unattached scope 2018-02-12 22:13:00 +02:00
Wojtek Wrona
40fabc3cc1
Use full class names when including concerns to avoid collisions 2018-02-12 16:37:54 +01:00
George Claghorn
cfcb92f9ea Add missing require 2018-02-11 18:30:09 -05:00
Eileen M. Uchitelle
b6ee4e4b98
Merge pull request #31927 from mrreynolds/patch-2
Document :combine_options
2018-02-09 09:18:11 -05:00
Robert Glaser
6ee504b1d7 Document :combine_options
Turns out this is still undocumented functionality.
2018-02-08 21:54:29 +01:00
Jason Lee
0625a2ba80 Fix blob.service_url for supports string or nil :filename option.
- Make sure `blob.service_url` present a `ActiveStorage::Filename` type to `serivce.url`.
- Add `ActiveStorage::Filename.wrap` method.

before:

```rb
blob.service_url(filename: ActiveStorage::Filename.new("new.txt"))

blob.service_url(filename: "new.txt")
=> NoMethodError: undefined method `parameters' for "new.txt":String

params = {}
blob.service_url(filename: params[:filename])
=> NoMethodError: undefined method `parameters' for nil:NilClass
```

after:

```rb
blob.service_url(filename: "new.txt")
blob.service_url(filename: nil)
```
2018-02-08 10:15:55 +08:00
Richard Macklin
c0368ad090 Include source code in published activestorage npm package
This allows activestorage users to ship smaller javascript bundles to
visitors using modern browsers, as demonstrated in this repository:
https://github.com/rmacklin/activestorage-es2015-build-example

In that example, the bundle shrinks by 5K (24%).

In addition to allowing smaller bundles for those who ship untranspiled
code to modern browsers, including the source code in the published
package can be useful in other ways:

1. Users can import individual modules rather than the whole library
2. As a result of (1), users can also monkey patch parts of
   activestorage by importing the relevant module, modifying the
   exported object, and then importing the rest of activestorage (which
   would then use the patched object).

Note:
In order to allow the source code to be depended on rather than the
compiled code, we have to declare the external dependency on spark-md5
as a regular dependency, not a development dependency.

This means that even users who depend on the compiled code will have to
download this package. However, spark-md5 is a small package, so this
tradeoff seems worth it.
2018-02-06 08:18:21 -08:00
George Claghorn
74aa62cb69
Merge pull request #31854 from huacnlee/allow-more-options-for-service-url
Allow ActiveStorage::Blob#service_url to pass addition options to service.url
2018-02-01 21:57:09 -05:00
Jason Lee
69ae9fe6b5 Allow ActiveStorage::Blob#service_url to pass addition options to service.url.
Because there have some service needs more parameters for file URL:

https://www.alibabacloud.com/help/doc-detail/44687.htm

```rb
class AliyunService < Service
  def url(key, options = {})
    image_process = options[:oss_process] || "image/resize,w_800"
    "http://image-demo.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=#{image_process}"
  end
end
```

Use case:

```erb
<%= image_tag @user.avatar.service_url(oss_process: "image/resize,m_fill,h_100,w_100" %>
```
2018-02-01 23:49:25 +08:00
Renaud Chaput
eafe2c16cd Use the full class name for the JSON coder, as there may be another
`JSON` constant defined.

For example when using the `representable` gem: https://github.com/trailblazer/representable/issues/224
2018-02-01 11:17:11 +00:00
George Claghorn
57cc6f4030 Correct orientation detection 2018-01-31 16:50:30 -05:00
George Claghorn
f9b806eaa1 Swap encoded image width and height if angle is 90 or 270 degrees 2018-01-31 15:43:29 -05:00
Rafael Mendonça França
1c383df324 Start Rails 6.0 development!!!
🎉🎉🎉
2018-01-30 18:51:17 -05:00
Shuhei Kitagawa
530a797055 Add a test for ActiveStorage::Blob#image? and ActiveStorage::Blob#video? 2018-01-29 09:02:17 +09:00
Shuhei Kitagawa
a5b3d5bf43 Eliminate ActiveStorage::Service::MirrorServiceTest#upload 2018-01-27 05:43:17 -05:00