Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
RDMS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
researchdata
RDMS
Commits
d0b5ebc6
Commit
d0b5ebc6
authored
1 year ago
by
Anusha Ranganathan
Browse files
Options
Downloads
Patches
Plain Diff
Cleaned up expiry conversion to seconds
parent
cd10a43f
Branches
feature/320-download-v2
Branches containing commit
Tags
Tags containing commit
1 merge request
!265
Feature/320 download v2
Pipeline
#12712
failed
1 year ago
Stage: build
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hyrax/app/services/s3_storage_service.rb
+3
-2
3 additions, 2 deletions
hyrax/app/services/s3_storage_service.rb
with
3 additions
and
2 deletions
hyrax/app/services/s3_storage_service.rb
+
3
−
2
View file @
d0b5ebc6
...
...
@@ -228,13 +228,14 @@ class S3StorageService
end
end
def
presigned_url_for_download
(
bucket_name
,
file_key
,
expiry
=
ENV
.
fetch
(
'S3_EXPIRY'
,
1
)
.
to_i
.
days
)
def
presigned_url_for_download
(
bucket_name
,
file_key
,
expiry
=
ENV
.
fetch
(
'S3_EXPIRY'
,
1
))
bucket
=
Aws
::
S3
::
Resource
.
new
(
region:
ENV
[
'S3_REGION'
]).
bucket
(
bucket_name
)
url_options
=
{
response_content_disposition:
"attachment; filename=
\"
#{
file_key
}
\"
"
}
url_options
[
:expires_in
]
=
expiry
.
to_i
if
expiry
.
present?
# S3_EXPIRY is in days. expiry.days.to_i converts it to seconds
url_options
[
:expires_in
]
=
expiry
.
to_i
.
days
.
to_i
if
expiry
.
present?
object
=
bucket
.
object
(
file_key
)
object
.
exists?
?
object
.
presigned_url
(
:get
,
url_options
).
to_s
:
nil
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment