Skip to main content

A set of use cases of boto3 wrapped into a module

Project description

s3_usecases_npcmr - a set of use cases of boto3 wrapped into a module.

Content

Installation

pip install s3_npcmr

Usage

Create your own class inheriting from ObjectStorage, set params.

from s3_npcmr import ObjectStorage as BaseObjectStorage

class ObjectStorage(BaseObjectStorage):
  S3_SERVICE_NAME = 'YOUR_PARAM'
  S3_ENDPOINT_URL = 'YOUR_PARAM'
  S3_BUCKET = 'YOUR_PARAM'
  REDIS_CONTAINER_NAME = 'YOUR_PARAM'

Upload a file

s3 = ObjectStorage()
s3.upload_file(file_as_bytes, unique_s3_key_for_this_file)

Get metadata

s3 = ObjectStorage()
data = s3.get_metadata(obj.s3_key).get('Metadata', {})
metadata =  {k.lower(): v for k, v in data.items()}

Get hashed links to files

s3 = ObjectStorage()
file_urls['watch'] = s3.get_presigned_url(obj.s3_key)
file_urls['download'] = s3.get_presigned_url(obj.s3_key, 'attachment')

Dependences

  • boto3
  • Redis (241.2 kB)

PYPI

TODO

  • make redis optional

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

s3_npcmr-0.0.2.tar.gz (1.8 kB view hashes)

Uploaded Source

Built Distribution

s3_npcmr-0.0.2-py3-none-any.whl (1.7 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