You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/s3.md
+64-9
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ const url = metadata.presign({
25
25
awaitmetadata.delete();
26
26
```
27
27
28
-
S3 is the [de facto standard](https://en.wikipedia.org/wiki/De_facto_standard) internet filesystem. You can use Bun's S3 API with S3-compatible storage services like:
28
+
S3 is the [de facto standard](https://en.wikipedia.org/wiki/De_facto_standard) internet filesystem. Bun's S3 API works with S3-compatible storage services like:
29
29
30
30
- AWS S3
31
31
- Cloudflare R2
@@ -42,7 +42,7 @@ There are several ways to interact with Bun's S3 API.
42
42
43
43
`Bun.s3` is equivalent to `new Bun.S3Client()`, relying on environment variables for credentials.
44
44
45
-
To explicitly set credentials, you can pass them to the `Bun.S3Client` constructor.
45
+
To explicitly set credentials, pass them to the `Bun.S3Client` constructor.
46
46
47
47
```ts
48
48
import { S3Client } from"bun";
@@ -76,7 +76,7 @@ Like `Bun.file(path)`, the `S3Client`'s `file` method is synchronous. It does ze
76
76
77
77
### Reading files from S3
78
78
79
-
If you've used the `fetch` API, you're familiar with the `Response` and `Blob` APIs. `S3File` extends `Blob`, so you can use the same methods on it as you would for a `Response` or a `Blob`.
79
+
If you've used the `fetch` API, you're familiar with the `Response` and `Blob` APIs. `S3File` extends `Blob`. The same methods that work on `Blob` also work on `S3File`.
80
80
81
81
```ts
82
82
// Read an S3File as text
@@ -231,7 +231,7 @@ const url = s3file.presign({
231
231
232
232
### `new Response(S3File)`
233
233
234
-
To quickly redirect users to a presigned URL for an S3 file, you can pass an `S3File` instance to a `Response` object as the body.
234
+
To quickly redirect users to a presigned URL for an S3 file, pass an `S3File` instance to a `Response` object as the body.
235
235
236
236
```ts
237
237
const response =newResponse(s3file);
@@ -258,6 +258,43 @@ Response (0 KB) {
258
258
259
259
Bun's S3 implementation works with any S3-compatible storage service. Just specify the appropriate endpoint:
260
260
261
+
### Using Bun's S3Client with AWS S3
262
+
263
+
AWS S3 is the default. You can also pass a `region` option instead of an `endpoint` option for AWS S3.
### Using Bun's S3Client with Google Cloud Storage
279
+
280
+
To use Bun's S3 client with [Google Cloud Storage](https://cloud.google.com/storage), set `endpoint` to `"https://storage.googleapis.com"` in the `S3Client` constructor.
281
+
282
+
```ts
283
+
import { S3Client } from"bun";
284
+
285
+
// Google Cloud Storage
286
+
const gcs =newS3Client({
287
+
accessKeyId: "access-key",
288
+
secretAccessKey: "secret-key",
289
+
bucket: "my-bucket",
290
+
endpoint: "https://storage.googleapis.com",
291
+
});
292
+
```
293
+
294
+
### Using Bun's S3Client with Cloudflare R2
295
+
296
+
To use Bun's S3 client with [Cloudflare R2](https://developers.cloudflare.com/r2/), set `endpoint` to the R2 endpoint in the `S3Client` constructor. The R2 endpoint includes your account ID.
To use Bun's S3 client with [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces/), set `endpoint` to the DigitalOcean Spaces endpoint in the `S3Client` constructor.
0 commit comments