Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download straight from the s3 bucket iwth displosbale s3 links. #472

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/controllers/hyrax/downloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ def item_identifier_for_irus_analytics

private

# OVERRIDE Hyrax 2.9.6 allow downloading directly from S3
def send_file_contents
if ENV['S3_DOWNLOADS']
s3_object = Aws::S3::Object.new(ENV['AWS_BUCKET'], file.digest.first.to_s.gsub('urn:sha1:', ''))
redirect_to s3_object.presigned_url(:get, expires_in: 300, response_content_disposition: "attachment\; filename=#{file.original_name}")
else
self.status = 200
prepare_file_headers
stream_body file.stream
end
end

# Override the Hydra::Controller::DownloadBehavior#content_options so that
# we have an attachement rather than 'inline'
def content_options
Expand Down
10 changes: 10 additions & 0 deletions ops/production-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ extraEnvVars: &envVars
value: "1"
- name: EXTERNAL_IIIF_URL
value: https://dudgkgvsbllzg.cloudfront.net/iiif/2
- name: AWS_BUCKET
value: "samvera-fcrepo-staging-bl"
- name: AWS_ACCESS_KEY_ID
value: $AWS_ACCESS_KEY_ID
- name: AWS_SECRET_ACCESS_KEY
value: $AWS_SECRET_ACCESS_KEY
- name: AWS_REGION
value: 'eu-west-1'
- name: S3_DOWNLOADS
value: "true"

worker:
replicaCount: 1
Expand Down
10 changes: 10 additions & 0 deletions ops/staging-deploy.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ ingress:
secretName: notch8cloudstaging

extraEnvVars: &envVars
- name: AWS_BUCKET
value: "samvera-fcrepo-staging-bl"
- name: AWS_ACCESS_KEY_ID
value: $AWS_ACCESS_KEY_ID
- name: AWS_SECRET_ACCESS_KEY
value: $AWS_SECRET_ACCESS_KEY
- name: AWS_REGION
value: 'eu-west-1'
- name: CONFDIR
value: "/app/samvera/hyrax-webapp/solr/config"
- name: DATABASE_ADAPTER
Expand Down Expand Up @@ -129,6 +137,8 @@ extraEnvVars: &envVars
value: "true"
- name: HYKU_ROOT_HOST
value: bl-staging.notch8.cloud
- name: S3_DOWNLOADS
value: "true"
- name: SMTP_ADDRESS
value: smtp.mailtrap.io
- name: SMTP_DOMAIN
Expand Down
Loading