Skip to main content

Parse and build Amazon S3 URLs

Project description

S3urls

Parse and build Amazon S3 URLs.

Usage

Parse S3 URLs

from s3urls import parse_url

>>> parse_url('https://my-bucket.s3.amazonaws.com/my-key/')
{'bucket': 'my-bucket', 'key': 'my-key/'}

>>> parse_url('https://s3-eu-west-1.amazonaws.com/my-bucket/my-key/')
{'bucket': 'my-bucket', 'key': 'my-key/'}

>>> parse_url('s3://my-bucket/my-key')
{'bucket': 'my-bucket', 'key': 'my-key/'}

>>> parse_url('s3://user@my-bucket/my-key')
{'bucket': 'my-bucket', 'key': 'my-key/', 'credential_name': 'user'}

Build S3 URLs

from s3urls import build_url

>>> build_url('s3', 'my-bucket', 'my-key/')
's3://my-bucket/my-key/'

>>> build_url('s3', 'my-bucket', 'my-key/', credential_name='user')
's3://user@my-bucket/my-key/'

>>> build_url('bucket-in-path', 'my-bucket', 'my-key/')
'https://s3.amazonaws.com/my-bucket/my-key/'

>>> build_url('bucket-in-path', 'my-bucket', 'my-key/', region='eu-west-1')
'https://s3-eu-west-1.amazonaws.com/my-bucket/my-key/'

>>> build_url('bucket-in-netloc', 'my-bucket', 'my-key/')
'https://my-bucket.s3.amazonaws.com/my-key/'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3urls-0.0.3.tar.gz (2.3 kB view hashes)

Uploaded source

Built Distribution

s3urls-0.0.3-py3-none-any.whl (2.5 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page