small bug-fixes

parent 21c5e5de
...@@ -33,6 +33,10 @@ client.login 'dspacedemo+admin@gmail.com', 'dspace' ...@@ -33,6 +33,10 @@ client.login 'dspacedemo+admin@gmail.com', 'dspace'
# create an community # create an community
client.communities.create(Dspace::Community.new({'name' => 'Testando'})) client.communities.create(Dspace::Community.new({'name' => 'Testando'}))
# get a bitstream and your file
bitstream = client.bitstreams.find(id: 20, expand: 'parent')
file = client.bitstreams.retrieve(id: 20)
``` ```
## Development ## Development
......
...@@ -13,6 +13,7 @@ require_relative "dspace/resources/status_resource" ...@@ -13,6 +13,7 @@ require_relative "dspace/resources/status_resource"
require_relative "dspace/resources/item_resource" require_relative "dspace/resources/item_resource"
require_relative "dspace/builders/hash_builder" require_relative "dspace/builders/hash_builder"
require_relative "dspace/builders/model_builder" require_relative "dspace/builders/model_builder"
require_relative "dspace/builders/tempfile_builder"
require_relative "dspace/community" require_relative "dspace/community"
require_relative "dspace/collection" require_relative "dspace/collection"
require_relative "dspace/item" require_relative "dspace/item"
......
...@@ -3,7 +3,7 @@ module Dspace ...@@ -3,7 +3,7 @@ module Dspace
module TempfileBuilder module TempfileBuilder
def self.build(filename, contents = nil) def self.build(filename, contents = nil)
file = Tempfile.new([sanitize_filename(name), File.extname(name)]).tap do |f| file = Tempfile.new([sanitize_filename(filename), File.extname(filename)]).tap do |f|
f.write contents f.write contents
f.close f.close
end end
......
...@@ -21,6 +21,7 @@ module Dspace ...@@ -21,6 +21,7 @@ module Dspace
def self.resources def self.resources
{ {
bitstreams: ::Dspace::Resources::BitstreamResource,
items: ::Dspace::Resources::ItemResource, items: ::Dspace::Resources::ItemResource,
collections: ::Dspace::Resources::CollectionResource, collections: ::Dspace::Resources::CollectionResource,
communities: ::Dspace::Resources::CommunityResource, communities: ::Dspace::Resources::CommunityResource,
......
...@@ -2,11 +2,6 @@ module Dspace ...@@ -2,11 +2,6 @@ module Dspace
module Resources module Resources
class BitstreamResource < ResourceKit::Resource class BitstreamResource < ResourceKit::Resource
# PUT /bitstreams/{bitstream id}/data - Update data/file of bitstream. You must put the data
# PUT /bitstreams/{bitstream id} - Update metadata of bitstream. You must put a Bitstream, does not alter the file/data
resources do resources do
default_handler(401) { raise NotAuthorizedError, 'This request requires authentication' } default_handler(401) { raise NotAuthorizedError, 'This request requires authentication' }
...@@ -56,12 +51,11 @@ module Dspace ...@@ -56,12 +51,11 @@ module Dspace
body { |upload_io| upload_io } body { |upload_io| upload_io }
handler(200, 201) { |response| true } handler(200, 201) { |response| true }
end end
end end
def retrieve(args={}) def retrieve(args={})
bitstream = ResourceKit::ActionInvoker.call(action(:find), self, id: args.fetch(:id)) bitstream = ResourceKit::ActionInvoker.call(action(:find), self, id: args.fetch(:id))
Dspace::Builders::TempfileBuilder.build bitstream.name, ResourceKit::ActionInvoker.call(action(:retrive), self) Dspace::Builders::TempfileBuilder.build(bitstream.name, ResourceKit::ActionInvoker.call(action(:retrive), self))
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment