Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/malexer/s3io
Access resources on Amazon S3 as a File Object.
https://github.com/malexer/s3io
Last synced: 3 days ago
JSON representation
Access resources on Amazon S3 as a File Object.
- Host: GitHub
- URL: https://github.com/malexer/s3io
- Owner: malexer
- License: mit
- Created: 2015-05-29T15:34:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-04T07:28:51.000Z (over 9 years ago)
- Last Synced: 2024-10-14T00:36:10.250Z (about 1 month ago)
- Language: Python
- Size: 137 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
====
s3io
====About
-----s3io is a minimalistic python module which provides file object access to data on S3.
All data manipulations are done via temporary local files - so you will actually work with local temp file which is a file object with all its methods supported.
Just keep in mind these facts:
1. Reading: the whole file will be downloaded to local temporary location at entering the context.
2. Writing: temp file will be provided at entering the context. Actual saving to S3 will be performed at exit from context. Thus such methods as ``flush`` will not influence the process of saving to S3.Dependencies
------------- `boto `_
Examples
--------s3io is intended to be used via context manager only.
There are three ways to provide access to s3:
1. Directly providing ``s3_connection``.
2. Providing credentials: ``aws_access_key_id`` and ``aws_secret_access_key``.
3. Providing ``profile_name``. This method is recommended to use. See `boto docs `_ for more info.Reading file using existing S3 connection::
import s3io
s3 = boto.connect_s3()
with s3io.open('s3:///', s3_connection=s3) as s3_file:
contents = s3_file.read()Reading file using credentials::
credentials = dict(
aws_access_key_id='',
aws_secret_access_key='',
)
with s3io.open('s3:///', **credentials) as s3_file:
contents = s3_file.read()Reading file using profile::
with s3io.open('s3:///', profile_name='') as s3_file:
contents = s3_file.read()Writing file using profile::
with s3io.open('s3:///', mode='w', profile_name='') as s3_file:
s3_file.write('Some data.')Exceptions
----------Possible exceptions:
1. s3io.BucketNotFoundError
2. s3io.KeyNotFoundError
3. s3io.UrlParseError