跳转到主要内容

Thumbor AWS扩展

项目描述

Thumbor AWS

Join the chat at https://gitter.im/thumbor-community/aws

Circle CI

安装

    pip install tc_aws

身份验证

身份验证由botocore处理,请参阅Boto3文档

起源故事

这是willtrking thumbor_aws的分支;由于该存储库不再维护,我们决定在thumbor-community组织下维护它。

贡献

首先您需要将此项目分支。在您的电脑上克隆您的仓库。接下来,在一个项目文件夹中

    make setup
    make test

如果所有测试都通过,您就有一个准备就绪的环境可以开始了。我们建议使用python-virtualevn(virtualenv和virtualenv-wrapper)

功能

  • tc_aws.loaders.s3_loader - 接受S3密钥路径和可选的存储桶名称,并通过S3 API下载文件。
  • tc_aws.result_storages.s3_storage
  • tc_aws.storages.s3_storage

S3加载器的目的是什么?

您可能会问自己为什么S3加载器是必要的?S3上的文件不是已经通过HTTP可用了吗?为什么您不直接将文件的S3 URL提供给Thumbor,并让它通过HTTP查询该文件呢?

如果您的S3资产不是公开的,您需要生成一个签名URL。每次您签名时,这个URL都会有所不同。Thumbor将无法理解这些URL都指向同一个文件,因此无法对其进行缓存。

S3加载器避免了这个问题,因为您只需在Thumbor URL中包含S3密钥名称。Thumbor本身将具有AWS授权密钥以获取文件。

使用的附加配置值

常规设置

# AWS Region the bucket is located in.
TC_AWS_REGION='eu-west-1'
# A custom AWS endpoint.
TC_AWS_ENDPOINT=''

加载器设置

当使用 tc_aws.loaders.s3_loader 时。

TC_AWS_STORAGE_BUCKET='' # S3 bucket for Storage
TC_AWS_STORAGE_ROOT_PATH='' # S3 path prefix for Storage bucket

# S3 bucket for Loader. If given, source urls are interpreted as keys
# within this bucket. If not given, source urls are expected to contain
# the bucket name, such as 's3-bucket/keypath'.
TC_AWS_LOADER_BUCKET=''

# S3 path prefix for Loader bucket. If given, this is prefixed to
# all S3 keys.
TC_AWS_LOADER_ROOT_PATH=''

# Enable HTTP Loader as well?
# This would allow you to load watermarks in over your images dynamically through a URI
# E.g.
# http://your-thumbor.com/unsafe/filters:watermark(http://example.com/watermark.png,0,0,50)/s3_bucket/photo.jpg
TC_AWS_ENABLE_HTTP_LOADER=False

TC_AWS_ALLOWED_BUCKETS=False # List of allowed bucket to be requested

存储设置

tc_aws.storages.s3_storage 启用时。

TC_AWS_STORAGE_BUCKET='' # S3 bucket for Storage
TC_AWS_STORAGE_ROOT_PATH='' # S3 path prefix for Storage bucket

# put data into S3 using the Server Side Encryption functionality to
# encrypt data at rest in S3
# https://aws.amazon.com/about-aws/whats-new/2011/10/04/amazon-s3-announces-server-side-encryption-support/
TC_AWS_STORAGE_SSE=False

# put data into S3 with Reduced Redundancy
# https://aws.amazon.com/about-aws/whats-new/2010/05/19/announcing-amazon-s3-reduced-redundancy-storage/
TC_AWS_STORAGE_RRS=False

结果存储设置

tc_aws.result_storages.s3_storage 启用时。

TC_AWS_RESULT_STORAGE_BUCKET='' # S3 bucket for result Storage
TC_AWS_RESULT_STORAGE_ROOT_PATH='' # S3 path prefix for Result storage bucket
TC_AWS_MAX_RETRY=0 # Max retries for get image from S3 Bucket. Default is 0

TC_AWS_STORE_METADATA=False # Store result with metadata (for instance content-type)

密钥设置

TC_AWS_RANDOMIZE_KEYS=False # Adds some randomization in the S3 keys for the Storage and Result Storage. Defaults to False for Backwards Compatibility, set it to True for performance.
TC_AWS_ROOT_IMAGE_NAME='root_image' # Sets a default name for requested images ending with a trailing /. Those images will be stored in result_storage and storage under the name set in this configuration.

故障排除

检查您的配置

您可能由于配置格式不正确而导致错误。例如,如果您已将值设置为 "None" 或 "",则将默认为字符串值,而不是期望的False或None值,这可能导致以后出现问题。因此,如果您遇到问题,请尝试重新阅读配置,注意格式。

使其与riak兼容

您可能需要稍微调整您的AWS配置(参见boto文档),最终应如下所示

[default]
aws_access_key_id = (KEY)
aws_secret_access_key =(SECRET)
s3 =
    signature_version = s3

项目详细信息


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

tc_aws-7.0.2.tar.gz (16.5 kB 查看散列)

上传

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面