@mapbox/s3urls
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/mapbox__s3urls package

2.0.0 • Public • Published

🌇 As of January 2020, this module is deprecated. It is provided as-is, with no warranty. We are not accepting new bugfixes or feature requests at this time.

s3Urls

Build Status

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

In a shell:

$ npm install -g @mapbox/s3urls

# Get URLs for a bucket/key
$ s3urls to-url my-bucket some/file/key
s3://my-bucket/some/file/key
https://s3.amazonaws.com/my-bucket/some/file/key
https://my-bucket.s3.amazonaws.com/some/file/key

# Get one type of URL for a bucket/key
$ s3urls to-url my-bucket some/file/key --type bucket-in-host
https://my-bucket.s3.amazonaws.com/some/file/key

# Convert a URL from one type to another (defaults to bucket-in-host type)
$ s3urls convert s3://my-bucket/some/file/key
https://my-bucket.s3.amazonaws.com/some/file/key

$ s3urls convert https://my-bucket.s3.amazonaws.com/some/file/key --type s3
s3://my-bucket/some/file/key

# Get a signed URL for a private object (default 600s expiration)
$ s3urls signed my-bucket some/file/key
https://my-bucket.s3.amazonaws.com/some/file/key?...

$ s3urls signed s3://my-bucket/some/file/key --expire 1200
https://my-bucket.s3.amazonaws.com/some/file/key?...

Readme

Keywords

none

Package Sidebar

Install

npm i @mapbox/s3urls

Weekly Downloads

6,938

Version

2.0.0

License

ISC

Unpacked Size

16.7 kB

Total Files

8

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user