Uploading images to R2 using rclone gives all images an `application/octet-stream` type
How can I use the image type when uploading images to R2 using rclone?
6 Replies
--header-upload "Content-type: text/html"
like
rclone copy example.png r2:img-bucket/ --header-upload "Content-type: image/png"
what if i'm using multiple image formats (jpg, png, webp, etc)? Currently the closest i've got to getting this working is using the wrangelr CLI tool, but that's obviously much slower
ideally i'd just be able to put rclone to a directory and recursively upload all images (regardless of their format type) to R2, but it sounds like this isn't possible?
if they end with the right extension, looks like rclone should use your system's mimetypes to convert: https://github.com/rclone/rclone/issues/2437
GitHub
Incorrect or missed Content-type based on file extension on move fr...
What is the problem you are having with rclone? Problem with setting correct Content-type to storage object on move command from machine with centOS 7 to Swift OpenStack. File extension is mp4. Mus...
it does seem fine for me
alternatively, you could build your own tool using a generic s3 library connecting to r2. There's tutorials for lots here: https://developers.cloudflare.com/r2/examples/aws/aws4fetch/
Cloudflare Docs
aws4fetch | Cloudflare R2 docs
You must generate an Access Key before getting started. All examples will utilize access_key_id and access_key_secret variables which represent the Access Key ID and Secret Access Key values you generated.
yeah I should clarify my images don't have extensions. I did try giving them extensions, but then rclone would upload them with the name
<hash>.<extension>.<extension>
, i.e. if a file was called abc.jpg
, the name in R2 would be abc.jpg.jpg
i guess I could fork rclone and tweak it to my needs, not ideal but at least there's that option if I really need it