-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* config for be-s3 * set bucket name and region direct in deploy yaml * use existing iam user so no need for these here * use existing defaults for s3 access * 🐛 Override BrowseEverything for S3 file size This commit will bring in an override for the BrowseEverything gem to retrieve the file size from an S3 object and pass it into the params so that the Bulkrax importer can use it. * remove file-system option from BE providers --------- Co-authored-by: Kirk Wang <[email protected]>
- Loading branch information
Showing
3 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
# OVERRIDE BrowseEverything v1.1.2 to add file_size for S3 files | ||
|
||
module BrowseEverything | ||
module Driver | ||
module S3Decorator | ||
def link_for(path) | ||
obj = bucket.object(full_path(path)) | ||
obj_head = obj.head | ||
file_size = obj_head.content_length | ||
|
||
extras = { | ||
file_name: File.basename(path), | ||
file_size: file_size, | ||
expires: (config[:expires_in] if config[:response_type] == :signed_url) | ||
}.compact | ||
|
||
url = case config[:response_type].to_sym | ||
when :signed_url then obj.presigned_url(:get, expires_in: config[:expires_in]) | ||
when :public_url then obj.public_url | ||
when :s3_uri then "s3://#{obj.bucket_name}/#{obj.key}" | ||
end | ||
|
||
[url, extras] | ||
end | ||
end | ||
end | ||
end | ||
|
||
BrowseEverything::Driver::S3.prepend(BrowseEverything::Driver::S3Decorator) |