Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lucacasonato/deno_s3

Amazon S3 for Deno
https://github.com/lucacasonato/deno_s3

aws deno s3

Last synced: about 1 month ago
JSON representation

Amazon S3 for Deno

Awesome Lists containing this project

README

        

# deno_s3

![ci](https://github.com/lucacasonato/deno_aws_sign_v4/workflows/ci/badge.svg)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/[email protected]/mod.ts)
[![Coverage Status](https://coveralls.io/repos/github/lucacasonato/deno_s3/badge.svg?branch=main)](https://coveralls.io/github/lucacasonato/deno_s3?branch=main)

Amazon S3 for Deno

> ⚠️ This project is work in progress. Expect breaking changes.

## Example

```ts
import { S3, S3Bucket } from "https://deno.land/x/[email protected]/mod.ts";

// 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",
region: "us-east-1",
endpointURL: Deno.env.get("S3_ENDPOINT_URL"),
});

const encoder = new TextEncoder();

// Put an object into a bucket.
await bucket.putObject("test", encoder.encode("Test1"), {
contentType: "text/plain",
});

// Retrieve an object from a bucket.
const { body } = await bucket.getObject("test");
const data = await new Response(body).text();
console.log("File 'test' contains:", data);

// List objects in the bucket.
const list = bucket.listAllObjects({});
for await (const obj of list) {
console.log("Item in bucket:", obj.key);
}

// Delete an object from a bucket.
await bucket.deleteObject("test");
```

## Contributing

To run tests you need to Docker and docker-compose installed.

```
make test
```