aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib/active_storage/service
Commit message (Collapse)AuthorAgeFilesLines
* GCS service: skip unnecessary bucket lookupsGeorge Claghorn2019-03-141-1/+1
|
* 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
|
* include the content type when uploading to S3Simo Leone2019-01-241-2/+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-274-21/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* 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-214-18/+68
| | | | | | | | | `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`.
* Camelize instead of classifyingGeorge Claghorn2018-08-061-1/+1
| | | | | | | Avoid mangling service names that end in S: "GCS".classify # => "GC" "GCS".camelize # => "GCS"
* Improve ActiveStorage service adapter error handlingJoel Taylor2018-08-061-1/+3
|
* Fix uploading Tempfiles to Azure StorageGeorge Claghorn2018-08-031-1/+1
| | | | Closes #32530.
* Remove another unused requireGeorge Claghorn2018-08-021-2/+0
|
* Remove unused requireGeorge Claghorn2018-08-011-2/+0
|
* Ignore concurrently-deleted files when deleting by prefix from GCSGeorge Claghorn2018-07-301-1/+7
|
* Support HTTP Range downloads from diskGeorge Claghorn2018-07-151-4/+4
| | | | Closes #32193.
* Remove vestigial require on ActiveStorage GCSServiceBibek Shrestha2018-07-041-1/+0
| | | | | | | | | | | | The file `filename.rb` as mentioned in `require "active_storage/filename"` belongs to the `app` folder while GCSService belongs to the lib folder. Looking at the git blame, it was added in commit https://github.com/rails/rails/commit/ccac681122db9747fec9512076772bca345e24b9#diff-bda6a610ef1575b2c8458c96b7f12578 where ActiveStorage::Filename was actually used. But it is no longer required on master and therefore can be removed. This allows anyone to use GCSService directly without enabling ActiveStorage engine.
* Support streaming downloads from Google Cloud StorageGeorge Claghorn2018-05-011-19/+25
|
* Avoid duplicating downloads from Google Cloud Storage in memoryGeorge Claghorn2018-04-291-2/+2
| | | | References #32703.
* Stream blobs from disk in 5 MB chunksGeorge Claghorn2018-04-291-1/+1
| | | | Match other services, which all use a 5 MB chunk size.
* Simplify URL generation for partial downloads from GCSGeorge Claghorn2018-04-251-1/+2
|
* Halve memory allocation in S3Service#downloadJanko Marohnić2018-04-231-1/+1
| | | | | | | | Aws::S3::Object#get returns a response with object content wrapped in an in-memory StringIO object. StringIO#read will return a copy of the content, which is not necessary because we can return the content directly using StringIO#string. This halves memory allocation of S3Service#download, because we remove unnecessary content duplication.
* Use a current model to provide the host for service urlsAndrew White2018-04-061-4/+7
| | | | | | | Trying to pass the current request down to the service so that it can create full urls instead of paths makes the API messy so use a model based on ActiveSupport::CurrentAttributes to provide the current host to services that need it (primarily the disk service).
* Allow full use of the AWS S3 SDK authentication options (#32270)Brian Knight2018-03-191-2/+2
| | | | | | | | | 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
* Fix Azure signed URL generation with newer client libGeorge Claghorn2018-03-121-6/+4
|
* Remove path config option from Azure serviceAndrew White2018-03-121-6/+10
| | | | | | | | | | | 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.
* Remove blank Content-Type from GCS direct upload headersGeorge Claghorn2018-03-061-1/+1
| | | | 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.
* Generate root-relative paths in Active Storage disk service URL methodsGeorge Claghorn2018-03-055-8/+48
| | | | Fixes #32129.
* Avoid specifying content types for direct uploads to Google Cloud StorageGeorge Claghorn2018-02-261-5/+4
| | | | Fix customizing the download Content-Type for a directly-uploaded blob via a signed URL. See e8286ee.
* Provide a sensible default hostGeorge Claghorn2018-01-161-1/+1
|
* Extract content types from blob dataGeorge Claghorn2018-01-151-17/+11
|
* Return `nil` instead of `false` if raise `Azure::Core::Http::HTTPError`Yoshiyuki Hirano2017-12-121-1/+1
| | | | | | | * If it raise error `Azure::Core::Http::HTTPError`, return `nil` instead of `false` in `ActiveStorage::Service::AzureStorageService#delete`. * Other services behave as same as this.
* Fix customizing Content-Type via GCS service URLsGeorge Claghorn2017-12-071-1/+7
|
* Fix instrumention name: delete_prefixed like the others.Kasper Timm Hansen2017-12-031-1/+1
|
* Purge variants with their blobsGeorge Claghorn2017-12-025-27/+68
|
* Use `credentials` instead of `keyfile` in GCS seviceyuuji.yaginuma2017-11-291-0/+2
| | | | | | | | | | | | | The `keyfile` was renamed to `credentials` in `google-cloud-storage` 1.8.0. https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/master/google-cloud-storage/CHANGELOG.md#180--2017-11-14 Although `keyfile` can still be used, but it looks like deprecate. https://github.com/GoogleCloudPlatform/google-cloud-ruby/blob/ddf7b2a856d676316525eb581c1a4cc83ca6097b/google-cloud-storage/lib/google/cloud/storage.rb#L589...L590 Therefore, I think that should use `credentials` in newly generated applications. Ref: https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues/1802
* Avoid connecting to GCS during app bootGeorge Claghorn2017-11-231-5/+12
|
* Remove needless block parameterGeorge Claghorn2017-11-071-1/+1
|
* Fix streaming downloads from S3/Azure StorageGeorge Claghorn2017-11-062-7/+7
| | | Closes #31073.
* Preview PDFs and videosGeorge Claghorn2017-09-284-7/+13
|
* Avoid making HTTP requests to generate signed URLs for GCS objectsGeorge Claghorn2017-09-131-3/+3
|
* Use v3 of the AWS SDKYuji Yaginuma2017-09-091-3/+3
|
* Accept GCS client optionsGeorge Claghorn2017-09-011-2/+2
|
* Ignore files already deleted on GCS file deletionsRosa Gutierrez2017-08-311-1/+5
| | | | | | | | Relying on the GET request issued first to fetch the file we want to delete is not enough to avoid this error. If the file is deleted after our GET request but before the DELETE request we'll get a NotFound error that after all means that the file is already deleted, so it can be safely ignored.
* Fix order of Active Storage DiskService URL parametersKoichi ITO2017-08-261-1/+1
| | | | `content_type` parameter is before `disposition` parameter.
* Fix syntax errorGeorge Claghorn2017-08-201-1/+1
|
* DRYGeorge Claghorn2017-08-204-10/+14
|
* Fix RuboCop offensesKoichi ITO2017-08-161-2/+2
| | | | And enable `context_dependent` of Style/BracesAroundHashParameters cop.