Skip to content
Snippets Groups Projects
Commit b950a1da authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

fix mime worker

parent 1e6f4d04
No related branches found
No related tags found
No related merge requests found
......@@ -4,13 +4,14 @@ class BitstreamMimeWorker
def perform(id)
attachment = LearningObject::Attachment.find(id)
client = DspaceService.create_client
return false if attachment.nil? || client.nil?
file = client.bitstreams.retrieve(id: attachment.id_dspace).open
begin
file = client.bitstreams.retrieve(id: attachment.id_dspace).open
mime = MimeMagic.by_magic(file)
attachment.update(format: mime.mediatype, mime_type: mime.type) unless mime.blank?
ensure
file.close unless file.nil?
file.unlink
end
end
end
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