Skip to content
Snippets Groups Projects
Commit a11b0acc authored by Anusha Ranganathan's avatar Anusha Ranganathan Committed by Pascal Ernster
Browse files

Bug fix/375 file not visible in viewer

parent db42f8c1
Branches
Tags
Loading
......@@ -14,7 +14,13 @@ ActiveSupport::Reloader.to_prepare do
end
Riiif::Image.file_resolver.id_to_uri = lambda do |id|
fs_id = id.sub(/\A([^\/]*)\/.*/, '\1')
# id is of the pattern
# /images/<fileset_id>/files/<uuid>/fcr:versions/version1/full/200,/0/default.jpg or
# <fileset_id>/files/<uuid>/fcr:versions/version1/full/200,/0/default.jpg
fs_id = id
fs_id = fs_id.gsub(/^\//, '') if fs_id.start_with?('/')
fs_id = fs_id.gsub(/^images\//, '') if fs_id.start_with?('images/')
fs_id = fs_id.split('/')[0] if fs_id.include?('/')
s3_file_url(fs_id)
end
......@@ -26,10 +32,11 @@ ActiveSupport::Reloader.to_prepare do
Riiif::Engine.config.cache_duration = 365.days
def s3_file_url(fs_id)
return "" unless fs_id
file_set = FileSet.find(fs_id)
return "" unless file_set.present?
s3 = S3StorageService.new
s3.init_client
file_set = FileSet.find(fs_id)
bucket_name = s3.sanitise_name(file_set.parent_works.first.id)
file_key = file_set.title.first
s3.presigned_url_for_download(bucket_name, file_key)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment