frantz / amazon-s3-uri

A URI wrapper that can parse out information about an S3 URI
MIT License
27 stars 11 forks source link

AmazonS3URI

Actions Status codecov

A URI wrapper that can parse out information about an S3 URI

Shamelessly adapted from https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/AmazonS3URI.java

with notable exceptions:

example

const AmazonS3URI = require('amazon-s3-uri')

try {
  const uri = 'https://bucket.s3-aws-region.amazonaws.com/key'
  const { region, bucket, key } = AmazonS3URI(uri)
} catch (err) {
  console.warn(`${uri} is not a valid S3 uri`) // should not happen because `uri` is valid in that example
}

license

MIT