small bug-fixes

parent 21c5e5de
......@@ -33,6 +33,10 @@ client.login 'dspacedemo+admin@gmail.com', 'dspace'
# create an community
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
......
......@@ -13,6 +13,7 @@ require_relative "dspace/resources/status_resource"
require_relative "dspace/resources/item_resource"
require_relative "dspace/builders/hash_builder"
require_relative "dspace/builders/model_builder"
require_relative "dspace/builders/tempfile_builder"
require_relative "dspace/community"
require_relative "dspace/collection"
require_relative "dspace/item"
......
......@@ -3,7 +3,7 @@ module Dspace
module TempfileBuilder
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.close
end
......
......@@ -21,6 +21,7 @@ module Dspace
def self.resources
{
bitstreams: ::Dspace::Resources::BitstreamResource,
items: ::Dspace::Resources::ItemResource,
collections: ::Dspace::Resources::CollectionResource,
communities: ::Dspace::Resources::CommunityResource,
......
......@@ -2,11 +2,6 @@ module Dspace
module Resources
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
default_handler(401) { raise NotAuthorizedError, 'This request requires authentication' }
......@@ -56,12 +51,11 @@ module Dspace
body { |upload_io| upload_io }
handler(200, 201) { |response| true }
end
end
def retrieve(args={})
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
......
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