Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
9c52f56f
Commit
9c52f56f
authored
9 months ago
by
nar20
Committed by
Richard Fernando Heise Ferreira
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue/61 download colections
parent
4b8ed71f
No related branches found
Branches containing commit
No related tags found
1 merge request
!56
Issue/61 download colections
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/concerns/downloadable_controller.rb
+19
-8
19 additions, 8 deletions
app/controllers/concerns/downloadable_controller.rb
with
19 additions
and
8 deletions
app/controllers/concerns/downloadable_controller.rb
+
19
−
8
View file @
9c52f56f
...
...
@@ -22,14 +22,25 @@ module DownloadableController
# GET /learning_objects/1/download
def
download
# Change request.remote_ip to req.env["HTTP_X_REAL_IP"] in production
downloadable
.
download
(
current_user
,
request
.
remote_ip
)
link
=
downloadable
.
download_link
if
!
link
.
blank?
redirect_to
link
else
render
status: :internal_server_error
end
object_id
=
params
.
values
[
2
]
object
=
LearningObject
.
where
(
id:
object_id
).
first
attachment_id
=
object
.
attachment_id
attachment
=
LearningObject
::
Attachment
.
where
(
id:
attachment_id
).
first
.
as_json
attachment_name
=
attachment
[
"name"
]
link
=
attachment
[
"retrieve_link"
]
source
=
"https://mecdb4.c3sl.ufpr.br:8443"
+
link
require
'open-uri'
data
=
URI
.
open
(
source
)
send_data
data
,
:disposition
=>
'attachment'
,
:filename
=>
attachment_name
# https://mecdb4.c3sl.ufpr.br:8443/rest/bitstreams/11104/retrieve
# https://api.portalmec.c3sl.ufpr.br/v1/learning_objects/10943/download
end
protected
...
...
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