-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add createBucket & getBucket method (#32)
- Loading branch information
Showing
10 changed files
with
386 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,24 @@ Amazon S3 for Deno | |
## Example | ||
|
||
```ts | ||
import { S3Bucket } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { S3, S3Bucket } from "https://deno.land/x/[email protected]/mod.ts"; | ||
|
||
const bucket = new S3Bucket({ | ||
// Create a S3 instance. | ||
const s3 = new S3({ | ||
accessKeyID: Deno.env.get("AWS_ACCESS_KEY_ID")!, | ||
secretKey: Deno.env.get("AWS_SECRET_ACCESS_KEY")!, | ||
region: "us-east-1", | ||
endpointURL: Deno.env.get("S3_ENDPOINT_URL"), | ||
}); | ||
|
||
// Create a new bucket. | ||
let bucket = await s3.createBucket("test", { acl: "private" }); | ||
|
||
// Get an existing bucket. | ||
bucket = s3.getBucket("test"); | ||
|
||
// Create a bucket instance manuely. | ||
bucket = new S3Bucket({ | ||
accessKeyID: Deno.env.get("AWS_ACCESS_KEY_ID")!, | ||
secretKey: Deno.env.get("AWS_SECRET_ACCESS_KEY")!, | ||
bucket: "test", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ const bucket = new S3Bucket({ | |
const encoder = new TextEncoder(); | ||
|
||
Deno.test({ | ||
name: "put object", | ||
name: "[bucket] put object", | ||
async fn() { | ||
await bucket.putObject("test", encoder.encode("Test1"), { | ||
contentType: "text/plain", | ||
|
@@ -24,7 +24,7 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "put object with % in key", | ||
name: "[bucket] put object with % in key", | ||
async fn() { | ||
await bucket.putObject( | ||
"ltest/versions/1.0.0/raw/fixtures/%", | ||
|
@@ -38,7 +38,7 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "put object with @ in key", | ||
name: "[bucket] put object with @ in key", | ||
async fn() { | ||
await bucket.putObject( | ||
"dex/versions/1.0.0/raw/lib/deps/[email protected]/README.md", | ||
|
@@ -54,7 +54,7 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "put object with 日本語 in key", | ||
name: "[bucket] put object with 日本語 in key", | ||
async fn() { | ||
await bucket.putObject( | ||
"servest/versions/1.0.0/raw/fixtures/日本語.txt", | ||
|
@@ -68,7 +68,7 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "head object success", | ||
name: "[bucket] head object success", | ||
async fn() { | ||
// setup | ||
await bucket.putObject("test", encoder.encode("Test1"), { | ||
|
@@ -92,14 +92,14 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "head object not found", | ||
name: "[bucket] head object not found", | ||
async fn() { | ||
assertEquals(await bucket.headObject("test2"), undefined); | ||
}, | ||
}); | ||
|
||
Deno.test({ | ||
name: "get object success", | ||
name: "[bucket] get object success", | ||
async fn() { | ||
// setup | ||
await bucket.putObject("test", encoder.encode("Test1"), { | ||
|
@@ -125,14 +125,14 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "get object not found", | ||
name: "[bucket] get object not found", | ||
async fn() { | ||
assertEquals(await bucket.getObject("test2"), undefined); | ||
}, | ||
}); | ||
|
||
Deno.test({ | ||
name: "delete object", | ||
name: "[bucket] delete object", | ||
async fn() { | ||
// setup | ||
await bucket.putObject("test", encoder.encode("test")); | ||
|
@@ -149,7 +149,7 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "copy object", | ||
name: "[bucket] copy object", | ||
async fn() { | ||
await bucket.putObject("test3", encoder.encode("Test1")); | ||
await bucket | ||
|
@@ -172,7 +172,7 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "list objects", | ||
name: "[bucket] list objects", | ||
async fn() { | ||
// setup | ||
const content = encoder.encode("Test1"); | ||
|
@@ -255,7 +255,7 @@ Deno.test({ | |
}); | ||
|
||
Deno.test({ | ||
name: "empty bucket", | ||
name: "[bucket] empty bucket", | ||
async fn() { | ||
// setup | ||
const content = encoder.encode("Test1"); | ||
|
Oops, something went wrong.