Skip to content
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

How to migrate files from local persistent storage with CarrierWave correctly? #62

Open
afuno opened this issue Jun 8, 2024 · 1 comment

Comments

@afuno
Copy link

afuno commented Jun 8, 2024

Initially, the application used local persistent storage. I tried moving the entire uploads directory into ImageKit. I kept the previous configuration and added a new one from ImageKit:

class BaseUploader < CarrierWave::Uploader::Base
  include ImageKitIo::CarrierWave

  def store_dir
    full_file_path
  end

  # ...

  def options
    {
      response_fields: "isPrivateFile, tags",
      tags: %w[images],
      use_unique_file_name: false,
      folder: full_file_path
    }
  end

  private

  # ...

  def full_file_path
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{dirs}"
  end

  # ...
end

As a result I get this error:

unexpected token at 'f1843b5f9.jpg'

From this line:

= image_tag band.card_image.url

In this case, the full name of the file in the database is: 9757131f1843b5f9.jpg.

Please tell me what else needs to be done to migrate files?

@afuno afuno changed the title How to migrate files correctly? How to migrate files from local persistent storage with CarrierWave correctly? Jun 8, 2024
@afuno
Copy link
Author

afuno commented Jun 8, 2024

This error comes from this place:

carrierwave/storage/ik_file.rb
def initialize(identifier)
  @identifier=JSON.parse(identifier)
  @imagekit = ImageKitIo.client
end

The variable identifier has the value 9757131f1843b5f9.jpg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant