@openaddresses/s3urls
TypeScript icon, indicating that this package has built-in type declarations

3.3.1 • Public • Published

s3Urls

From bucket/key to URL and the other way around

Usage

In javascript:

var s3urls = require('@mapbox/s3urls');
var assert = require('assert');

var url = s3urls.toUrl('my-bucket', 'some/key');
assert.deepEqual(url, {
  's3': 's3://my-bucket/some/key',
  'bucket-in-path': 'https://s3.amazonaws.com/my-bucket/some/key',
  'bucket-in-host': 'https://my-bucket.s3.amazonaws.com/some/key'
});

var url = 'https://s3.amazonaws.com/my-bucket/some/key';
if (s3urls.valid(url)) {
  var result = s3urls.fromUrl(url);
  assert.deepEqual(result, {
    Bucket: 'my-bucket',
    Key: 'some/key'
  });
}

Readme

Keywords

none

Package Sidebar

Install

npm i @openaddresses/s3urls

Weekly Downloads

82

Version

3.3.1

License

ISC

Unpacked Size

17 kB

Total Files

12

Last publish

Collaborators

  • ingalls
  • iandees