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 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page