Skip to content

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

Open

Description

@afuno

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?

Activity

  1. changed the title [-]How to migrate files correctly?[/-] [+]How to migrate files from local persistent storage with CarrierWave correctly?[/+] on Jun 8, 2024
  2. afuno commented on Jun 8, 2024

    @afuno
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions