-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove carrierwave dependency from Spotlight, relying on ActiveStorage #2739
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,10 @@ def initialize | |
end | ||
|
||
def pattern(id) | ||
uploaded_file = Spotlight::FeaturedImage.find(id).image.file | ||
uploaded_file = Spotlight::FeaturedImage.find(id).image.blob | ||
raise Riiif::ImageNotFoundError, "unable to find file for #{id}" if uploaded_file.nil? | ||
|
||
uploaded_file.file | ||
ActiveStorage::Blob.service.path_for(uploaded_file.key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how this will work with other types of ActiveStorage::Service, but should those people just write their own file resolver? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah.. I think we might have to adapt RIIIF to handle some of this better. I think (but... the whole download-with-a-block API won't play nice with RIIIF) |
||
end | ||
end | ||
end |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,42 @@ namespace :spotlight do | |
Migration::PageLanguage.run | ||
end | ||
|
||
desc 'Migrate CarrierWave content to ActiveStorage' | ||
task migrate_carrier_wave: :environment do | ||
puts 'Mirating Spotlight::Attachment' | ||
Spotlight::Attachment.find_each do |attachment| | ||
next if attachment.file.blob | ||
|
||
attachment.file.attach( | ||
io: File.open(Rails.root.join("public/uploads/spotlight/attachment/file/#{attachment.attributes['file']}")), | ||
filename: attachment.attributes['file'], | ||
content_type: Mime::Type.lookup_by_extension(File.extname(attachment.attributes['file'])[1..]) | ||
) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we clean up the old files? |
||
|
||
puts 'Mirating Spotlight::FeaturedImage' | ||
Spotlight::FeaturedImage.find_each do |featured_image| | ||
next if featured_image.image.blob | ||
|
||
featured_image.image.attach( | ||
io: File.open(Rails.root.join("public/uploads/spotlight/featured_image/image/#{featured_image.attributes['image']}")), | ||
filename: featured_image.attributes['image'], | ||
content_type: Mime::Type.lookup_by_extension(File.extname(featured_image.attributes['image'])[1..]) | ||
) | ||
end | ||
|
||
puts 'Mirating Spotlight::BulkUpdate' | ||
Spotlight::BulkUpdate.find_each do |bulk_update| | ||
next if bulk_update.file.blob | ||
|
||
bulk_update.file.attach( | ||
io: File.open(Rails.root.join("public/uploads/#{bulk_update.attributes['file']}")), | ||
filename: bulk_update.attributes['file'], | ||
content_type: Mime::Type.lookup_by_extension(File.extname(bulk_update.attributes['file'])[1..]) | ||
) | ||
end | ||
end | ||
|
||
def prompt_to_create_user | ||
Spotlight::Engine.user_class.find_or_create_by!(email: prompt_for_email) do |u| | ||
puts 'User not found. Enter a password to create the user.' | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super weird, but seems like we need to provide the accessible url at this point for our uploader forms to work correctly.