Read and write files to S3 using a file-like object. Refer to S3 buckets and keys using full URLs.
The underlying mechanism is a lazy read and write using cStringIO as the file emulation. This is an in memory buffer so is not suitable for large files (larger than your memory).
As S3 only supports reads and writes of the whole key, the S3 key will be read in its entirety and written on close. Starting from release 1.2 this read and write are deferred until required and the key is only read from if the file is read from or written within and only updated if a write operation has been carried out on the buffer contents.
More tests and docs are needed.
Requirements
boto
Usage
Basic usage:
from s3file import s3open
f = s3open("http://mybucket.s3.amazonaws.com/myfile.txt")
f.write("Lorem ipsum dolor sit amet...")
f.close()
with statement:
with s3open(path) as remote_file:
remote_file.write("blah blah blah")
S3 authentication key and secret may be passed into the s3open method or stored in the boto config file.:
f = s3open("http://mybucket.s3.amazonaws.com/myfile.txt", key, secret)
Other parameters to s3open include:
- expiration_days
Sets the number of days that the remote file should be cached by clients. Default is 0, not cached.
- private
If True, sets the file to be private. Defaults to False, publicly readable.
- content_type
The content_type of the file will be guessed from the URL, but you can explicitly set it by passing a content_type value.
- create
New in version 1.1 If False, assume bucket exists and bypass validation. Riskier, but can speed up writing. Defaults to True.
Metadata
Release files for python-s3file 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-s3file-1.3.tar.gz | 5.8 kB | Without provenance | Details for python-s3file-1.3.tar.gz |
Release files / python-s3file-1.3.tar.gz
| Download URL | python-s3file-1.3.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19d0a6a4472ece8bec57ccbe7c8715c7d185ee811015bc8d963fc54ba7de7119
|
|
BLAKE2b-256 checksum How to use checksums |
c4c46878442a2fc1b42b4dea971560b568b3b8c3b87eadb4f4ea8596ccd01f84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for python-s3file 1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.