Skip to content
Snippets Groups Projects

Issue/61 download colections

Merged nar20 requested to merge issue/61-download-colections into develop
1 file
+ 19
8
Compare changes
  • Side-by-side
  • Inline
@@ -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
Loading