apiexamples
Browse
Pricing
Docs
Have a key?
Get All-Access — $19
Browse
/
Cloudflare
/
R2: Upload Object
R2: Upload Object
Cloudflare
$19 · Pro
Upload a file to Cloudflare R2 storage (S3-compatible API).
TypeScript
Node
Python
Go
PHP
Ruby
r2-upload-object.ts
await
r2Client
.
send
(
new
PutObjectCommand
({
Bucket
:
bucketName
,
Key
:
objectKey
,
Body
:
fileBody
,
ContentType
:
"application/pdf"
}));
Unlock the full snippet
This is a Pro snippet — get all-access for $19, or unlock just this one snippet for $1.
Get All-Access — $19
Unlock just this one — $1
Already paid? Enter your key
Related snippets
MongoDB
TypeScript
Insert a Document
Insert a document into a MongoDB collection using the official driver.
const result = await collection.insertOne(newCustomer);
$19 · Pro
View →
MongoDB
TypeScript
Update a Document
Update a document in a MongoDB collection using the official driver.
const result = await subscribers.updateOne(filter, update);
$19 · Pro
View →
MongoDB
TypeScript
Query Documents
Query documents from a MongoDB collection with a filter using the official driver.
const cursor = orders.find(filter).sort({ createdAt: -1 }).limit(20);
$19 · Pro
View →
R2: Upload Object — Cloudflare Example (TypeScript, Node, Python, Go, PHP, Ruby) | apiexamples