Skip to content

Commit

Permalink
Add remove and download from amazon functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
horstenwillem committed May 10, 2019
1 parent 589c012 commit fda1597
Show file tree
Hide file tree
Showing 5 changed files with 2,830 additions and 1,968 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const options = {
destination: 'uploads',
fileSize: 12000,
allowedFileTypes: ['image/png', 'image/jpg'],

// Optional Joi schema validation for other body data
validator: {
schema: joiSchema,
Expand Down Expand Up @@ -127,7 +127,27 @@ const options = {
key: 's3KeyName',
encryption: 'AE-256', // Optional encryption (this will enable server encryption on S3)
};
const { location, bucket, key } = amazon.uploadFile(client, options);
const { location, bucket, key } = await amazon.uploadFile(client, options);
```

### getFile(client, bucket, key)

Retrieve a file from S3

```javascript
import { amazon } from '@icapps/tree-house-storage'

const { Body } = await amazon.getFile(client, bucket, key);
```

### removeFile(client, bucket, key)

Remove a file from S3

```javascript
import { amazon } from '@icapps/tree-house-storage'

await amazon.removeFile(client, bucket, key);
```

### getPresignedUrl(client, options)
Expand All @@ -142,7 +162,7 @@ const options = {
key: 's3KeyName',
expires: 1600, // Optional expiration time
};
const { location, bucket, key } = amazon.getPresignedUrl(client, options);
const { location, bucket, key } = await amazon.getPresignedUrl(client, options);
```

## Tests
Expand Down

0 comments on commit fda1597

Please sign in to comment.