ossurls
v1.5.2
Published
Create OSS urls from region/bucket/key or extract region/bucket/key from them
Downloads
5
Readme
ossUrls
From bucket/key to URL and the other way around
Usage
In javascript:
var ossUrls = require('ossUrls');
var assert = require('assert');
var url = ossUrls.toUrl('oss-cn-beijing','my-bucket', 'some/key');
assert.deepEqual(url, {
'oss': 'oss://oss-cn-beijing/my-bucket/some/key',
'bucket-in-host': 'https://my-bucket.oss-cn-beijing.aliyuncs.com/some/key'
});
In a shell:
$ npm install -g ossUrls
# Get URLs for a bucket/key
$ ossUrls to-url oss-cn-beijing my-bucket some/file/key
oss://oss-cn-beijing/my-bucket/some/file/key
https://my-bucket.oss-cn-beijing.aliyuncs.com/some/file/key
# Get one type of URL for a bucket/key
$ ossUrls to-url oss-cn-beijing my-bucket some/file/key --type bucket-in-host
https://my-bucket.oss-cn-beijing.aliyuncs.com/some/file/key
# Convert a URL from one type to another (defaults to bucket-in-host type)
$ ossUrls convert oss://oss-cn-beijing/my-bucket/some/file/key
https://my-bucket.oss-cn-beijing.aliyuncs.com/some/file/key
$ ossUrls convert https://my-bucket.oss-cn-beijing.aliyuncs.com/some/file/key --type oss
oss://oss-cn-beijing/my-bucket/some/file/key