-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6091 from samvera/5504-deriviatives-were-harder-t…
…o-find-than-wifes-headphones thumbnails and other derivatives were not stored in the path we expected them to be
- Loading branch information
Showing
4 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
# this class overrides the Valkyrie::Storage::Disk::BucketStorage class so that file paths match | ||
module Hyrax | ||
class DerivativeBucketedStorage | ||
attr_reader :base_path | ||
|
||
def initialize(base_path:) | ||
@base_path = base_path | ||
end | ||
|
||
# rubocop:disable Lint/UnusedMethodArgument | ||
def generate(resource:, file:, original_filename:) | ||
raise ArgumentError, "original_filename must be provided" unless original_filename | ||
Pathname.new(base_path).join(*bucketed_path(resource.id)).join(original_filename) | ||
end | ||
# rubocop:enable Lint/UnusedMethodArgument | ||
|
||
def bucketed_path(id) | ||
# We want to use the same code the derivative process uses so that items end up | ||
# stored in the place we expect them. | ||
Hyrax::DerivativePath.new(id.to_s).pair_directory | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters