Skip to main content

Django application for handling graphics resources served in a S3 Amazon webservice

Settings

Settings example:

# Configuration example

S3_BUCKET_NAME = 'bucket-name'                      # The name of the bucket we are working with
S3_AWS_ACCESS_KEY_ID = 'AWS_ACCESS_KEY_ID'          # AWS access key
S3_AWS_SECRET_ACCESS_KEY = 'AWS_SECRET_ACCESS_KEY'  # AWS secret access key
S3_LOCAL_PATH = tempfile.gettempdir()               # Path where to put downloaded files.
S3_UPLOAD_DIR_PATH = tempfile.gettempdir()          # Path where to search files for uploading.
S3_AWS_BASE_URL = 'http://s3.amazonaws.com/'        # Base url for Amazon S3 services.
S3_CATEGORY_MAP = {                                 # Map code - category, this is for organizing the
    'B':  'BACKGROUND',                              # the folders in the bucket.
    'F':  'VASE',
    'CF': 'CLIPPING-FLOWER',
    'WF': 'WRAPPING-FLOWER',
    'CR': 'CATALOGUE-PRODUCT',
    'PP': 'PERSONALIZED-PRODUCT',
    'CM': 'COMPOSITION'
}

INSTALLED_APPS = [
    'django_s3',                                    # Add the app to installed apps.
]

Transport

Transport is the class for download and upload resources.

Downloading a resource

from django_s3.transport import Transport
from django_s3.resource import Resource

rource = Resource('some_name.jpg')
transport = Transport()
filename = transport.download(resource)

Uploading a resource

from django_s3.transport import Transport
from django_s3.resource import Resource

rource = Resource('some_name.jpg')
transport = Transport()
filename = transport.upload(resource)

Downloading a resource by name

from django_s3.transport import Transport
from django_s3.resource import Resource

filename = transport.download('some_name.jpg')

Resource

Class for holding information about resources. A resource’s name has to follow the following name convention:

<code><serial>_<rest_of_the_resource_name><size>.<extension>

  • : Upper case letters that identify the resource type (Ex. ‘BG’ for Backgrounds)

  • : A serial number unique for every resource.

  • : String for a name.

  • : The size of the image (Ex. 800x600)

  • : The image’s extension.

# Example that shows how to get info about a resource.

from django_s3.resource import Resource

 rource = Resource('some_name.jpg')
 code = resource.code               # The code of the type.
 size = resource.size               # The size, as a 2-tuple value.
 extension = resource.extension     # The extension
 category = resource.category       # The category mapped to the code.
 url = resource.url                 # The url where to find the resource

All this attributes are read-only, and computed at creation time.

Browser

A class for walking through the bucket filesystem.

from django_s3.browser import Browser
from django_s3.browser import FileTreeNode


browser = Browser()
root_node = browser.walk()                  # Returns the whole directory tree.
node = browser.walk('path/to/some/node')    # Returns the directory tree relative to the path
                                            # passed by parameter

# You can check for the node type as well
if node.type == FileTreeNode.DIR:
    pass

if node.type == FileTreeNode.File:
    pass

Accessing resource info using Resource class.

Just create a new resource instance and query it for its metadata.

from django_s3.browser import Browser

browser = Browser()
node = browser.walk('path/to/some/node')    # Returns the directory tree relative to the path
                                            # passed by parameter
resource = Resource(node.name)              # Now you can see metadata for resources.

Metadata

Release files for real-django-s3 1.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for real-django-s3 1.2.4
File Size Uploaded
real-django-s3-1.2.4.tar.gz 21.8 kB Details

Release files / real-django-s3-1.2.4.tar.gz

Download URL real-django-s3-1.2.4.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e66fb8b752d4a0e3a0ec316902825bd33e25621a68b97825494aa35edcf0de93
BLAKE2b-256 checksum
How to use checksums
25419e9cfc3bf2f223b0165a2bd131b9d1d13793b0eb75dd06f1ec8515eba14c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.2.8

1 release file

1.2.7

1 release file

1.2.6

1 release file

1.2.5

1 release file

This release

1.2.4 This release

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2

1 release file

1.1

1 release file

0.3

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page