Not Able to Get Derivatives

Hi all,

Following the Upgrading from Paperclip guide, I managed to migrate image data from Paperclip to Shrine. Everything works as expected in local environment but it returns an empty hash when I am trying to access derivatives in staging environment on EC2.

Image data seems correctly written

> BlogUser.last.thumbnail_data

=> "{\"id\":\"blog_users/1016/original_profile.jpg\",\"storage\":\"store\",\"metadata\":{\"size\":55295,\"filename\":\"profile.jpg\",\"mime_type\":\"image/jpeg\"},\"derivatives\":{\"large\":{\"id\":\"bloguser/18/thumbnail/large-22cb0c2ab7342f80f3053a0d6854ecbd.jpg\",\"storage\":\"store\",\"metadata\":{\"filename\":\"image_processing20200623-12027-xyl9vo.jpg\",\"size\":60731,\"mime_type\":\"image/jpeg\"}},\"medium\":{\"id\":\"bloguser/18/thumbnail/medium-d918c55ba341e04326fe7cb581d0cfeb.jpg\",\"storage\":\"store\",\"metadata\":{\"filename\":\"image_processing20200623-12027-gwjcf8.jpg\",\"size\":60731,\"mime_type\":\"image/jpeg\"}},\"thumb\":{\"id\":\"bloguser/18/thumbnail/thumb-16c49d4981ea4eafe80a8c4e79e0ef10.jpg\",\"storage\":\"store\",\"metadata\":{\"filename\":\"image_processing20200623-12027-ip3b5h.jpg\",\"size\":35560,\"mime_type\":\"image/jpeg\"}},\"oblong\":{\"id\":\"bloguser/18/thumbnail/oblong-081a3a3644c09e218f5043cc88d70fc6.jpg\",\"storage\":\"store\",\"metadata\":{\"filename\":\"image_processing20200623-12027-mol2yf.jpg\",\"size\":42906,\"mime_type\":\"image/jpeg\"}},\"small\":{\"id\":\"bloguser/18/thumbnail/small-f5f95c1f2c40abd09cbbde3e273b575c.jpg\",\"storage\":\"store\",\"metadata\":{\"filename\":\"image_processing20200623-12027-5uq7yh.jpg\",\"size\":46581,\"mime_type\":\"image/jpeg\"}}}}"

It has no problem getting the url of the original image but that of derivatives

> BlogUser.last.thumbnail_url
=> "https://s3.ap-northeast-1.amazonaws.com/my-domain/blog_users/1016/original_profile.jpg?X-Amz-Algorithm= ...omitted ..."

> BlogUser.last.thumbnail_derivatives
=> {}

> BlogUser.last.thumbnail_url(:small)
=> nil

> BlogUser.last.thumbnail_url(:medium)
=> nil

BlogUser & Uploader

class BlogUser < ApplicationRecord
  include ImageUploader::Attachment(:thumbnail)
  ... omitted ...
end

class ImageUploader < Shrine
  plugin :derivatives
end

Shrine Version: 3.2.1
Rails Version: 5.2.4

@Maxence

Thank you for the reply.

I am able to access the thumbnail attachment like below:

> BlogUser.last.thumbnail
=> #<UploadImageUploader::UploadedFile storage=:store id="blog_users/1016/original_profile.jpg" metadata={"size"=>55295, "filename"=>"profile.jpg", "mime_type"=>"image/jpeg"}>

However, when I try BlogUser.last.thumbnail(:thumb).url I get undefined method url for nil:NilClass as it still returns nil from BlogUser.last.thumbnail(:thumb)

Correction On The Original Post:

Return value of BlogUser.last.thumbnail_data should be:

"{\"id\":\"blog_users/1016/original_profile.jpg\",\"storage\":\"store\",\"metadata\":{\"size\":55295,\"filename\":\"profile.jpg\",\"mime_type\":\"image/jpeg\"},\"derivatives\":{\"large\":{\"id\":\"blog_users/1016/large_profile.jpg\",\"storage\":\"store\",\"metadata\":{}},\"medium\":{\"id\":\"blog_users/1016/medium_profile.jpg\",\"storage\":\"store\",\"metadata\":{}},\"thumb\":{\"id\":\"blog_users/1016/thumb_profile.jpg\",\"storage\":\"store\",\"metadata\":{}},\"oblong\":{\"id\":\"blog_users/1016/oblong_profile.jpg\",\"storage\":\"store\",\"metadata\":{}},\"small\":{\"id\":\"blog_users/1016/small_profile.jpg\",\"storage\":\"store\",\"metadata\":{}}}}"

Or in Hash format:

{"id"=>"blog_users/1016/original_profile.jpg",
 "storage"=>"store",
 "metadata"=>
  {"size"=>55295, "filename"=>"profile.jpg", "mime_type"=>"image/jpeg"},
 "derivatives"=>
  {"large"=>
    {"id"=>"blog_users/1016/large_profile.jpg",
     "storage"=>"store",
     "metadata"=>{}},
   "medium"=>
    {"id"=>"blog_users/1016/medium_profile.jpg",
     "storage"=>"store",
     "metadata"=>{}},
   "thumb"=>
    {"id"=>"blog_users/1016/thumb_profile.jpg",
     "storage"=>"store",
     "metadata"=>{}},
   "oblong"=>
    {"id"=>"blog_users/1016/oblong_profile.jpg",
     "storage"=>"store",
     "metadata"=>{}},
   "small"=>
    {"id"=>"blog_users/1016/small_profile.jpg",
     "storage"=>"store",
     "metadata"=>{}}}}

Sorry I replied too fast. I thought the thumbnail was a derivative, as it is in fact an attachment.
Then I canceled my answer because I see nothing wrong. Especially if it works locally.
Are you sure your production/staging database show the same data as your local database ?