hyrax
hyrax copied to clipboard
Collection Branding Fails Upload if using S3
Descriptive summary
When using S3 backed file uploads, a call to file.file_url will return a http based url. This gets passed in to https://github.com/samvera/hyrax/blob/master/app/models/collection_branding_info.rb#L22 where FileUtils.cp is called. FileUtils doesn't know about remote files and thus throws an exception. We're seeing this in Hyku, based on Hyrax 2.3.3, but the code looks unchanged in master as well.
Rationale
As a user when I upload a banner or icon for a collection I expect that the banner or icon to upload successfully.
Actual behavior
If Carrierwave is set to anything other than local files (S3 as a common example) the code will throw Errno::ENOENT (No such file or directory @ rb_sysopen
exception.
Steps to reproduce the behavior
- Set up Hyrax with Carrierwave settings for S3
- Create a collection
- Edit that collection and set either a banner or a logo
Possible Fix
By adding code to make sure the file is locally cached to the controller at here and here we were able to work around this problem
if file.file_url.match(/^http/)
file.file.download!(file.file_url)
end
After the call to download! file.file_url will return the locally cached copy.
working on this as follow-up to #4836.
@orangewolf I wonder if you could test this PR: https://github.com/samvera/hyrax/pull/5491
I'm thinking this could fix this issue. I just don't have S3 setup.