JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2599
  • Score
    100M100P100Q123733F
  • License MIT

Amazon S3 tokenizer

Package Exports

  • @tokenizer/s3
  • @tokenizer/s3/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tokenizer/s3) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Node.js CI NPM version npm downloads Known Vulnerabilities Total alerts Language grade: JavaScript

@tokenizer/s3

Specialized tokenizer to access files stored on the Amazon Web Services (AWS) S3 cloud storage.

Installation

Install using npm:

npm install @tokenizer/s3 @aws-sdk/client-s3

or using yarn:

yarn add install @tokenizer/s3 @aws-sdk/client-s3

To configure AWS client authentication see Configuration and credential file settings.

Examples

Determine S3 file type

Determine file type (based on it's content) from a file stored Amazon S3 cloud:

const FileType = require('file-type');
const { S3Client } = require('@aws-sdk/client-s3');
const { makeTokenizer } = require('@tokenizer/s3');

(async () => {

  // Initialize S3 client
  const s3 = new S3Client({});

  // 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);
})();

See also example at file-type.

Reading audio metadata from Amazon S3

Retrieve music-metadata

const s3tokenizer = require("@tokenizer/s3");
const { S3Client } = require('@aws-sdk/client-s3');
const mm = require("music-metadata/lib/core");

/**
 * Retrieve metadata from Amazon S3 object
 * @param objRequest S3 object request
 * @param options music-metadata options
 * @return Metadata
 */
async function parseS3Object(s3, objRequest, options) {
  const s3Tokenizer = await  s3tokenizer.makeTokenizer(s3, objRequest, options);
  return mm.parseFromTokenizer(s3Tokenizer, options);
}

(async () => {
  const s3 = new S3Client({});

  const metadata = await parseS3Object(s3, {
    Bucket: 'standing0media',
    Key: '01 Where The Highway Takes Me.mp3'
    }
  );

  console.log(metadata);
})();

An module implementation of this example can be found in @music-metadata/s3.

Dependency graph

dependency graph