sqlalchemy_imageattach.stores.s3
— AWS S3 backend storage¶The backend storage implementation for Simple Storage Service provided by Amazon Web Services.
sqlalchemy_imageattach.stores.s3.
BASE_URL_FORMAT
= 'https://{0}.s3.amazonaws.com'¶(str
) The format string of base url of AWS S3.
Contains no trailing slash.
Default is 'https://{0}.s3.amazonaws.com'
.
sqlalchemy_imageattach.stores.s3.
DEFAULT_MAX_AGE
= 31536000¶(numbers.Integral
) The default max-age
seconds of
Cache-Control. It’s the default value of
S3Store.max_age
attribute.
sqlalchemy_imageattach.stores.s3.
AuthMechanismError
(url, code, msg, hdrs, fp)¶Raised when the bucket doesn’t support Signature Version 2 (AWS2Auth) anymore but supports only Signature Version 4 (AWS4Auth).
For the most part, it can be resolved by determining
S3Store.region
.
New in version 1.1.0.
sqlalchemy_imageattach.stores.s3.
S3Request
(url, bucket, access_key, secret_key, data=None, headers={}, method=None, content_type=None)¶Remained for backward compatibility. Use S3RequestV2
(which was renamed) or S3RequestV4
(which is the current
standard).
Deprecated since version 1.1.0: Renamed to S3RequestV2
.
sqlalchemy_imageattach.stores.s3.
S3RequestV2
(url, bucket, access_key, secret_key, data=None, headers={}, method=None, content_type=None)¶HTTP request for S3 REST API which does authentication using Signature Version 2 (AWS2Auth) which has been deprecated since January 30, 2014.
New in version 1.1.0.
Changed in version 1.1.0: Renamed from S3Request
(which is now deprecated).
sqlalchemy_imageattach.stores.s3.
S3RequestV4
(url, bucket, region, access_key, secret_key, data=None, headers={}, method=None, content_type=None)¶HTTP request for S3 REST API which does authentication using Signature Version 4 (AWS4Auth).
New in version 1.1.0.
sqlalchemy_imageattach.stores.s3.
S3SandboxStore
(underlying, overriding, access_key=None, secret_key=None, max_age=31536000, underlying_prefix='', overriding_prefix='', underlying_region=None, overriding_region=None, max_retry=5)¶It stores images into physically two separated S3 buckets while
these look like logically exist in the same store. It takes two buckets
for read-only and overwrite: underlying
and overriding
.
It’s useful for development/testing purpose, because you can use the production store in sandbox.
Parameters: |
|
---|---|
Raises: | Raised when the |
New in version 1.1.0: The underlying_region
, overriding_region
, and max_retry
parameters.
DELETED_MARK_MIMETYPE
= 'application/x-sqlalchemy-imageattach-sandbox-deleted'¶All keys marked as “deleted” have this mimetype as its Content-Type header.
sqlalchemy_imageattach.stores.s3.
S3Store
(bucket, access_key=None, secret_key=None, max_age=31536000, prefix='', public_base_url=None, region=None, max_retry=5)¶Image storage backend implementation using S3. It implements
Store
interface.
If you’d like to use it with Amazon CloudFront, pass the base url of
the distribution to public_base_url
. Note that you should configure
Forward Query Strings to Yes when you create the distribution.
Because SQLAlchemy-ImageAttach will add query strings to public URLs
to invalidate cache when the image is updated.
Parameters: |
|
---|---|
Raises: | Raised when the |
New in version 1.1.0: The region
and max_retry
parameters.
Changed in version 0.8.1: Added public_base_url
parameter.
max_age
= None¶(numbers.Integral
) The max-age
seconds of
Cache-Control.
region
= None¶(str
) The region code that the bucket
belongs to.
If None
it authenticates using Signature Version 2 (AWS2Auth)
which has been deprecated since January 30, 2014. Because Signature
Version 4 (AWS4Auth) requires to determine the region code before
signing API requests.
Since recent regions don’t support Signature Version 2 (AWS2Auth) but
only Signature Version 4 (AWS4Auth), if you set region
to
None
and bucket
doesn’t support Signature Version 2
(AWS2Auth) anymore AuthMechanismError
would be raised.
New in version 1.1.0.