איך אני מעביר את דלי ההעלאה שלי S3 מספק אחד לאחר?

סיכום מבוסס בינה מלאכותית

seeminglee is migrating their S3 upload bucket from AWS to Linode and successfully set up new uploads, but old posts still reference AWS URLs. Falco suggests syncing buckets and using the posts:remap rake task to update URLs in posts. seeminglee tries remapping with full URLs but gets 0 posts remapped. Falco advises using protocol-relative URLs (e.g., //...) and seeminglee tests variations, still with no success. Falco then recommends inspecting Upload objects directly via Rails console to verify the stored URLs: Upload.order(Arel.sql('RANDOM()')).limit(10).pluck(:id, :url). merefield praises the question and advice, suggesting it could become a howto guide. The core issue appears to be matching the exact URL format stored in the database, which may not include the protocol or may have subtle differences preventing the remap from finding matches.

I have setup my upload bucket originally on AWS, but I want to now use Linode. Setup went well and I can see that images are being uploaded to the Linode already.

However, when I look at the old posts, they are still pointing to AWS. How can I move those images to Linode so that I can remove the bucket on AWS?

Thanks!

First sync the buckets using a software that can do it (aws cli, s3cmd, etc) and then do a Replace a string in all posts

I’ve just run this

rake posts:remap["https://royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com/","https://royaleapi-discuss-upload.ap-south-1.linodeobjects.com/"]

but it says 0 posts remapped

Even though I can see that that the URL is correct, e.g. by looking at the image URL here:

https://discuss.royaleapi.com/t/idea-for-season-21-the-archers-time/320

Try

rake posts:remap["//royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com/","//royaleapi-discuss-upload.ap-south-1.linodeobjects.com/"]

Tried your suggestion. Also tried

rake posts:remap["royaleapi-discuss-uploads.s3.dualstack.ap-northeast-1.amazonaws.com","royaleapi-discuss-upload.ap-south-1.linodeobjects.com"]

Got the same result:

Remapping

0 posts remapped!

Is there a different command to find all posts that don’t do any replacing to see if the command can actually find valid hits?

You want to inspect the Upload objects:

cd /var/discourse
./launcher enter app
rails c
Upload.order(Arel.sql('RANDOM()')).limit(10).pluck(:id, :url)

Excellent question and advice. Should be a howto ?