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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s3_npcmr-0.0.2-py3-none-any.whl (1.7 kB view details)

Uploaded Python 3

File details

Details for the file s3_npcmr-0.0.2.tar.gz.

File metadata

  • Download URL: s3_npcmr-0.0.2.tar.gz
  • Upload date:
  • Size: 1.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for s3_npcmr-0.0.2.tar.gz
Algorithm Hash digest
SHA256 295e8672048376a36227ca56d1ce038fff3c0fb7c1f3abd0e6dc3a7448a420c9
MD5 45804960eddb2cf87f8e02f5887f0a64
BLAKE2b-256 9d3d0a85aff74a1953e1f61e388b480701df6947cbfd30afee3c3dcd71f84b4b

See more details on using hashes here.

File details

Details for the file s3_npcmr-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: s3_npcmr-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 1.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for s3_npcmr-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8edb3ca5e7f8d49c2aff5b716d6d0097141a23f07933f8d9421aba90d9a9e55d
MD5 e2e6d1b7803f91e121cf7311a8ded45a
BLAKE2b-256 94868828cb99ec6c11e45327f69cc853222ed47422be59ab13c11cd4d5b8ac7e

See more details on using hashes here.

Supported by

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