Cloudflare R2 Storage Issues

AI-generated summary

A user is experiencing issues with Cloudflare R2 Storage for file uploads. While images upload and load correctly, files do not load properly for download, redirecting to an incorrect URL. The user has shared their S3 settings and seeks assistance. pfaffman suggests moving S3 settings to environment variables for better security and easier backup restoration, and recommends sharing a topic with the issue for further investigation.

Hi,

I setup Cloudflare R2 as the S3 bucket for file uploads. Images upload and load properly. However files upload but do not load properly for download.

My API URL looks like:

http://d9d………..r2.cloudflarestorage.com/jtechforums-storage

My CDN URL looks like:

https://pub-c5c38…..9bc6cb.r2.dev/jtechforums-storage

Images load properly, however when trying to download files, the file URL it takes me to is:

https://jtechforums-storage.jtechforums-storage/original/2X/a/a55867475418180f5c6e62b572ad5769a78ac548.pdf

Why does that happen?

Attached are my S3 settings.

I"m not quite sure, but I recommend that you put your S3 settings in ENV variables as described at Configure an S3 compatible object storage provider for uploads. You’re likely to have trouble restoring a backup with the settings in the database.

Also, if you do have them in app.yml and have the backup on S3, then you need only the yml file to set up a new server and restore the database.

If it’s possible, sharing a topic where you have this problem will give someone trying to see what’s going on a lot more information. If your site is public, then the only thing you need to hide are your keys, which are already hidden.