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
a4cedb76
Commit
a4cedb76
authored
11 months ago
by
nar20
Browse files
Options
Downloads
Patches
Plain Diff
[add] new download route
parent
9d7185d3
No related branches found
No related tags found
1 merge request
!56
Issue/61 download colections
Pipeline
#38213
failed
11 months ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/concerns/downloadable_controller.rb
+14
-19
14 additions, 19 deletions
app/controllers/concerns/downloadable_controller.rb
with
14 additions
and
19 deletions
app/controllers/concerns/downloadable_controller.rb
+
14
−
19
View file @
a4cedb76
...
...
@@ -22,30 +22,25 @@ module DownloadableController
# GET /learning_objects/1/download
def
download
Rails
.
logger
.
info
"
\n\n
So far...
\n
So good...
\n\n
"
object_id
=
params
.
values
[
2
]
Rails
.
logger
.
info
"This is my learning_object id:
#{
object_id
}
\n\n
"
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"
]
# how it used to be (not working) #
# 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
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
# an idea on how to proceed #
# extension= #get file extension
# send_file Rails.root.join('public', 'uploads', #file),
# :type=>"aplicattion/#{extension[1]}", :x_sendfile=>true
# 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