s3path is a pathlib extension for AWS S3 Service


Keywords
amazon-s3, amazon-web-services, aws-s3, boto3, python, python3, s3-sdk
License
Apache-2.0
Install
pip install s3path==0.1.92

Documentation

S3Path

Latest version

S3Path CI

S3Path provide a Python convenient File-System/Path like interface for AWS S3 Service using boto3 S3 resource as a driver.

Like pathlib, but for S3 Buckets

AWS S3 is among the most popular cloud storage solutions. It's object storage, is built to store and retrieve various amounts of data from anywhere.

Currently, Python developers use Boto3 as the default API to connect / put / get / list / delete files from S3.

S3Path blends Boto3's ease of use and the familiarity of pathlib api.

Install:

From PyPI:

From Conda:

Basic use:

The following example assumes an s3 bucket setup as specified bellow:

Importing the main class:

Listing "subdirectories" - s3 keys can be split like file-system with a / in s3path we:

Listing html source files in this "directory" tree:

Navigating inside a "directory" tree:

Querying path properties:

Opening a "file" (s3 key):

Or Simply reading:

Versioned S3 Objects:

s3path supports versioned objects for S3 buckets that have versioning enabled. VersionedS3Path is a subclass of S3Path that supports all of its features. The main difference is an additional required version_id keyword parameter in each of its constructor methods.

New in version 0.5.0

Requirements:

  • Python >= 3.4
  • boto3
  • smart-open

Further Documentation: