Coder Social home page Coder Social logo

tokenizer-s3's Introduction

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

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

See also example at file-type.

Reading audio metadata from Amazon S3

Retrieve music-metadata

const s3tokenizer = require("@tokenizer/s3");
const S3 = require('aws-sdk/clients/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 S3();

  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

tokenizer-s3's People

Contributors

borewit avatar dependabot-preview[bot] avatar monken avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.