Skip to content

Commit

Permalink
Describe S3 file access.
Browse files Browse the repository at this point in the history
As suggested in #331.
  • Loading branch information
Borewit committed Feb 13, 2020
1 parent 93ea843 commit 1144bb5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,30 @@ const audioTrackUrl = 'https://test-audio.netlify.com/Various%20Artists%20-%2020
})();
```

Or use [@tokenizer/s3](https://github.com/Borewit/tokenizer-s3) to determine the file type of file stored on the [Amazon S3 cloud](https://aws.amazon.com/s3):
```js
const FileType = require('file-type');
const S3 = require('aws-sdk/clients/s3');
const { makeTokenizer } = require('@tokenizer/s3');

(async () => {

// Initialize S3 client
const s3 = new S3();

// Initialize S3 tokenizer
const s3Tokenizer = await makeTokenizer(s3, {
Bucket: 'affectlab',
Key: '1min_35sec.mp4'
});

// Figure out what kind of file it is
const fileType = await FileType.fromTokenizer(s3Tokenizer);
console.log(fileType);
})();
```
Note that only that data is read which is required to determine the file type (okay, just a bit extra to prevent to many fragmented reads).

#### tokenizer

Type: [`ITokenizer`](https://github.com/Borewit/strtok3#tokenizer)
Expand Down

0 comments on commit 1144bb5

Please sign in to comment.