Skip to content

Instantly share code, notes, and snippets.

@seanmcn
Last active March 30, 2017 08:22
Show Gist options
  • Save seanmcn/6360d4090c63ea1d5c5b to your computer and use it in GitHub Desktop.
Save seanmcn/6360d4090c63ea1d5c5b to your computer and use it in GitHub Desktop.
[Dspace] Get assetstore file path of bitstream using database
/*
Replace :asset_store_path, :handle and :sequence_id
*/
select
':asset_store_path' ||
substring(bit.internal_id, 1, 2) || '/' ||
substring(bit.internal_id, 3, 2) || '/' ||
substring(bit.internal_id, 5, 2) || '/' ||
bit.internal_id
from bitstream bit
inner join bundle2bitstream b2b on b2b.bitstream_id=bit.bitstream_id
inner join bundle b on b.bundle_id=b2b.bundle_id and b.name='ORIGINAL'
inner join item2bundle i2b on i2b.bundle_id=b.bundle_id
inner join handle h on i2b.item_id=h.resource_id
where h.handle=':handle' and bit.sequence_id =:sequence_id;
@tsega
Copy link

tsega commented Mar 30, 2017

@seanmcn could you enlighten me on how this works? I'm trying to create an API endpoint based on the DSpace database that get the item with its metadata and bitstream (PDF or JPG) files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment