Images and Avatars Uploaded before Move to S3 Have Incorrect URLs


(Corey J. Mahler) #1

I recently moved one of my sites over to an S3-compatible storage solution. Apparently, the move broke some links to some older images (i.e., those uploaded before the move). Everything is updated, I’ve rebuilt the app, and I’ve rebaked all posts.

Example
Both the site logo and the site icon loaded properly in the “Assets for the site design” topic (i.e., the thumbnails loaded properly), but when clicked they 404ed (i.e., the originals were unavailable); after rebaking all posts, the thumbnails also do not load.

The thumbnails appeared to be loading from the uploads directory (i.e., they appear not to have been moved over to S3), and they do not appear to be present on S3. The URLs for the originals also point to the uploads directory, but they do appear to be present on S3 (i.e., just the URLs are wrong).

Suggestions?

n.b., this may be related to a bug reported here.


(Jeff Atwood) #2

I believe @tgxworld has expertise in this and may be able to offer advice.

Do we have any kind of howto on this @jomaxro, when someone changes storage type on their Discourse or moves from the Real™ Amazon S3 to a “S3 compatible” clone service?


(Alan Tan) #3

I’m assuming the move was done using the uploads:migrate_to_s3 rake task. What branch are you currently on?


(Corey J. Mahler) #4

Yes, I ran that task. I’m on the most current beta (2.2.0.beta5).

Update: I just attempted to run the uploads:migrate_to_s3 task again (just to see what would happen); it did not fix the outstanding issue and caused additional problems (i.e., it corrupted URLs of working images).


(Alan Tan) #5

What does the following give you?

./launcher enter app
rails c
Upload.order(id: :asc).first.url

You might want to censor the hash from the output before pasting it here.


(Corey J. Mahler) #6

"/original/1X/ea17a258eff7a95045bda914c10bac5a2de02c62.png"


(Alan Tan) #7

Did you see any output like Migrating #{from} --> #{to} took during the migration? It seems like the remapping never happened for some reason.


(Corey J. Mahler) #8

I believe I did (it’s been a week or two); I know that I saw that when I just ran the script again to see what would happen. However re-running the script did not fix the broken images and broke the working images.