CLI tool for uploading files to Cloudflare R2 with animated terminal UI and progress tracking
Complete documentation of r2put's automatic MIME type detection.
r2put automatically detects content types from file extensions. The detected MIME type is used when uploading files to R2.
| Extension | Content Type |
|---|---|
| jpg, jpeg | image/jpeg |
| png | image/png |
| gif | image/gif |
| webp | image/webp |
| svg | image/svg+xml |
| application/pdf | |
| json | application/json |
| txt | text/plain |
| html | text/html |
| css | text/css |
| js | application/javascript |
| ts | application/typescript |
| zip | application/zip |
| tar | application/x-tar |
| gz | application/gzip |
| bin, pkg, exe | application/octet-stream |
| mp4 | video/mp4 |
| mp3 | audio/mpeg |
| wav | audio/wav |
| (unknown) | application/octet-stream |
.JPG, .jpg, .Jpg all map to image/jpegfile.tar.gz → application/gzip (from .gz)archive.backup.tar → application/x-tar (from .tar)application/octet-streamapplication/octet-stream# Image files
r2put --file ./image.jpg --bucket my-bucket
# Detects: image/jpeg
r2put --file ./photo.png --bucket my-bucket
# Detects: image/png
# Document files
r2put --file ./document.pdf --bucket my-bucket
# Detects: application/pdf
r2put --file ./data.json --bucket my-bucket
# Detects: application/json# Case-insensitive matching
r2put --file ./IMAGE.JPG --bucket my-bucket
# Detects: image/jpeg
r2put --file ./Photo.Png --bucket my-bucket
# Detects: image/png# Uses last extension
r2put --file ./archive.tar.gz --bucket my-bucket
# Detects: application/gzip (from .gz)
r2put --file ./backup.old.tar --bucket my-bucket
# Detects: application/x-tar (from .tar)# Unknown extension falls back to application/octet-stream
r2put --file ./data.unknown --bucket my-bucket
# Detects: application/octet-stream
# No extension falls back to application/octet-stream
r2put --file ./data --bucket my-bucket
# Detects: application/octet-streamr2put uses extension-based detection only. It does not:
r2put does not support:
For specific MIME type control, use @cfkit/r2 directly:
import { R2 } from '@cfkit/r2';
const r2 = new R2({
accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
accessKeyId: process.env.R2_ACCESS_KEY_ID!,
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY!,
});
await r2.putObject({
bucket: 'my-bucket',
key: 'file.bin',
body: fileContent,
contentType: 'application/custom-type', // Custom MIME type
});Rename files to use recognized extensions:
# Rename file to use recognized extension
mv data.custom data.bin
r2put --file ./data.bin --bucket my-bucket
# Detects: application/octet-stream@cfkit/r2 directly for custom MIME typesSymptoms:
Resolution:
@cfkit/r2 directly to set specific MIME typeSymptoms:
application/octet-streamResolution:
application/octet-stream@cfkit/r2 directly for custom MIME typesInstall with Tessl CLI
npx tessl i tessl/npm-r2put