imagekit-developer / imagekit-developer/imagekit-ruby

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

Open
#62 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
19
Forks
8
Avg merge
47m
Merged PRs (30d)
1

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the BaseUploader configuration and the image_tag band.card_image.url call shown in the issue. Reproduce the failure using the existing database filename and inspect the CarrierWave/ImageKit migration and URL-handling documentation; done means migrated files can be resolved and rendered without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.