Oh, makes indeed more sense
You could check locally with any ssh client that you like, depending on your setup, the files should be in something like /var/discourse/shared/standalone/uploads/default/original/2X/
so you might ls -R /var/discourse/shared/standalone/uploads/ | grep 4064b to find the 4064b…d.png
Talking about the same Discourse instance as @masterakay here.
We switched over to s3 over 2 years ago, none of the files in the local uploads directory are newer than 2018.
As I understand, images are uploaded in the “original” folder, and processed (cropped, reduced in size, etc.) and put in the “optimized” folder. The URLs used by discourse when uploading images are still from the “/original/1X/” folder. Somehow, with the upgrade, the “1X” folder is gone.
There’s a “default” folder which as a lot of uploads (images, etc.) as well as cropped versions. There are about 10k files here making it ~2.5 GB.
The problem is the image URL in the posts always have the “original” one.
Something we noticed is that the missing files are a subset of the files in the “default” folder.
New uploads work without issues and are stored in “/original/2X/”.
Does anyone have ideas where the “/original/1X/” folder may have gone and if it possible to bring it back?
@sam@codinghorror I’m so sorry to drag you into this, but it’s quite urgent. We’re students and sort of helpless with the college mounting pressure on us to fix the images.
How do you have S3 setup? Did you set any values in app.yml or just in the admin UI? It looks like something is unexpected for DISCOURSE_S3_BUCKET or DISCOURSE_S3_BACKUP_BUCKET.
Indeed. Something may not be working right in the code, but we don’t know what nor why. So we need more information.
There are two different ways to setup S3: You can configure the environment in app.yml or you can enter the values in the admin UI. The variables are named slightly differently in each.
The topic you linked to describes how to setup in the admin UI. If that is how you setup your site, can you tell us what you have for s3_upload_bucket, and s3_backup_bucket?
The problem happened because those settings are not supposed to be the same value – search the setup topic for the line “Do I really need to use separate buckets for uploads and backups?”
A maintenance job ran on the contents of the backup bucket and affected the uploads because their values overlapped.
@sam we should probably enforce that in code, not just documentation
To fix up your site, there’s two steps:
First, you’ll need to change the backups prefix – adding /backups to the end as described in the setup topic, is sufficient.
After, move everything in the S3 bucket back into the correct place. Everything in the top “default” folder should get put back at the top level.
E.g. there’s probably “default/originals” folder there which should be moved up.
You’ll have to use the AWS web console or some other tool to browse the bucket.
Hey @schleifer that makes sense and added the backups prefix to the bucket name.
As for the existing uploads, all the uploads are in /default/ (not in sub-folders). The image urls in posts (and everywhere else) use /original/* or /optimized/*.
If we move everything in the default folder up one level (to the root), then the images will be in /*.
And no, there aren’t any folders within defaults, just upload files. It seems to contain files with standard 40-char hash filename as well as some with suffixes like “_2_10x10” (which I presume are from optimized).
How do you suggest fixing this? Fixing all posts with new links will take time. Is it possible to somehow group the files in the correct folders based on this filename?
The new uploads are working as expected into sub-folders, fortunately. And the links in posts point to the correct location.
There are >10k files in /default/. Editing each post manually seems like a lot of work. Is there any way to script this? Maybe with a regex replace on all posts?
That’s the plan, yes. The next thing to do is put all the AWOL files in a known location. In the bucket, what sub-directories are there under /original/? There should be /1X/ and there may be others.