hyrax icon indicating copy to clipboard operation
hyrax copied to clipboard

Collection Branding Fails Upload if using S3

Open orangewolf opened this issue 6 years ago • 2 comments

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

  1. Set up Hyrax with Carrierwave settings for S3
  2. Create a collection
  3. 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.

orangewolf avatar Jan 18 '19 06:01 orangewolf

working on this as follow-up to #4836.

no-reply avatar Mar 30 '21 00:03 no-reply

@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.

blancoj avatar Mar 03 '22 21:03 blancoj