Rebaking old posts won't pull new S3 CDN URL after S3 bucket rename

Ooh, good news. While researching how to find the Upload records, I came across this post which showed me how to convert the base62 string to the sha1 hash.

It mentioned images that just show the transparent.png had been tombstoned. I’m not entirely sure what that means, but I assume a process ran overnight while the images were broken and marked them as not in use. I was able to run

rake uploads:recover_from_tombstone

and it seems all my embedded images have came back and are now pointing to my S3 CDN!

And for what it’s worth, here how I found the Upload record starting with the yTDVQSa4wbIeLGEZvE7muXe8sAJ string.

[14] pry(main)> Base62.decode("yTDVQSa4wbIeLGEZvE7muXe8sAJ").to_s(16)
=> "f49428d6af35d7e0414408ccb65e7316f5003215"
[15] pry(main)> Upload.where( "original_filename ilike '%f49428d6af35d7e0414408ccb65e7316f5003215%'" )
=> [#<Upload:0x000056313aa91fe8
  id: 899,
  user_id: 549,
  original_filename: "f49428d6af35d7e0414408ccb65e7316f5003215.png",
  filesize: 25514,
  width: 1169,
  height: 984,
  url: "//ortus-discourse-uploads.s3.dualstack.us-west-2.amazonaws.com/original/1X/f49428d6af35d7e0414408ccb65e7316f5003215.png",
  created_at: Tue, 12 Jan 2021 23:01:35 UTC +00:00,
  updated_at: Tue, 12 Jan 2021 23:01:36 UTC +00:00,
  sha1: "f49428d6af35d7e0414408ccb65e7316f5003215",
  origin: nil,
  retain_hours: nil,
  extension: "png",
  thumbnail_width: 594,
  thumbnail_height: 500,
  etag: "6977f35ddbf39a4399dc76f92a5079d4",
  secure: false,
  access_control_post_id: nil,
  original_sha1: nil,
  animated: nil,
  verification_status: 1>]

Thank you again for your assistance @Falco I’m new to Discourse but you’ve proven very patient and helpful :+1:

3 Likes