Skip to content
Snippets Groups Projects
Commit 139c3041 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Added dspace gem to workers

parent f02dc2a7
No related branches found
No related tags found
No related merge requests found
...@@ -14,12 +14,12 @@ class V1::LearningObjects::ChunksController < ApplicationController ...@@ -14,12 +14,12 @@ class V1::LearningObjects::ChunksController < ApplicationController
if last_chunk? if last_chunk?
combine_file! combine_file!
attachment = post_file! attachment = post_file!
render attachment, status: 200 render json: attachment, status: :ok
else else
render status: 200 render status: :ok
end end
rescue rescue
render status: 500 render status: :internal_server_error
end end
private private
......
...@@ -7,6 +7,9 @@ class DeleteBitstreamWorker ...@@ -7,6 +7,9 @@ class DeleteBitstreamWorker
attachment = LearningObject::Attachment.find(attachment_id) attachment = LearningObject::Attachment.find(attachment_id)
return false if attachment.blank? || !wait_bitstream(attachment) return false if attachment.blank? || !wait_bitstream(attachment)
# Require dspace gem
Bundler.require(*Rails.groups)
DspaceService.create_client.bitstreams.delete(id: attachment.id_dspace) DspaceService.create_client.bitstreams.delete(id: attachment.id_dspace)
end end
......
...@@ -11,6 +11,9 @@ class DspaceUploadWorker ...@@ -11,6 +11,9 @@ class DspaceUploadWorker
return false if learning_object.blank? return false if learning_object.blank?
# Require dspace gem
Bundler.require(*Rails.groups)
# create attachment # create attachment
file = File.new(media_path, 'r') file = File.new(media_path, 'r')
bitstream = dspace.items.add_bitstream(file, id: learning_object.id_dspace, name: File.basename(media_path), description: description) bitstream = dspace.items.add_bitstream(file, id: learning_object.id_dspace, name: File.basename(media_path), description: description)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment