-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/controllers/api/active_storage_blobs_proxy_legacy_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
class ActiveStorageBlobsProxyLegacyController < ApiBaseController | ||
include ActiveStorage::Streaming | ||
|
||
skip_before_action :authenticate_user! | ||
skip_authorization_check | ||
|
||
def show | ||
Rollbar.info('Blob legacy') if defined?(Rollbar) | ||
|
||
return render json: { error: 'Not authenticated' }, status: :unauthorized unless current_user | ||
|
||
blob = ActiveStorage::Blob.find_signed!(params[:signed_blob_id] || params[:signed_id]) | ||
|
||
if blob.attachments.none? { |a| a.record.account.id == current_user.account_id } | ||
Rollbar.error("Blob account not found: #{blob.id}") if defined?(Rollbar) | ||
|
||
return head :not_found | ||
end | ||
|
||
if request.headers['Range'].present? | ||
send_blob_byte_range_data blob, request.headers['Range'] | ||
else | ||
http_cache_forever public: true do | ||
response.headers['Accept-Ranges'] = 'bytes' | ||
response.headers['Content-Length'] = blob.byte_size.to_s | ||
|
||
send_blob_stream blob, disposition: params[:disposition] | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters