跳转到主要内容

thumbor_aws为使用AWS的thumbor提供扩展

项目描述

thumbor-aws

这是一个提供现代thumbor>7.0.0 AWS扩展的项目。

Coverage Status

⚙️ 安装

pip install thumbor-aws

🎯 特点

  • 异步非阻塞AWS S3支持
  • 符合thumbor 7的新存储和结果存储规范
  • Python 3兼容
  • S3图像加载器 - 从S3加载源图像
  • S3存储 - 获取和存储源图像、检测数据和安全密钥
  • S3结果存储 - 获取和存储结果图像
  • 为tc_aws用户兼容模式:目前支持的加载器、存储和结果存储

使用方法

配置thumbor

配置您的thumbor.conf文件,使其指向thumbor_aws

## The loader thumbor should use to find source images.
## This must be the full name of a python module (python must be able to import it)
LOADER = "thumbor.loaders.http_loader"

## The file storage thumbor should use to store original images.
## This must be the full name of a python module (python must be able to import it)
STORAGE = 'thumbor_aws.storage'

## The result storage thumbor should use to store generated images.
## This must be the full name of a python module (python must be able to import it)
RESULT_STORAGE = 'thumbor_aws.result_storage'

您应仅使用您用例所需的扩展。它们之间没有依赖关系。

配置

thumbor-aws 允许您独立配置每个扩展

通用

某些 S3 提供商在上传新对象时无法返回有效的位置头。对于这种情况,thumbor-aws 允许用户设置要使用的位置模板。

## Default location to use if S3 does not return location header.
## Can use {bucket_name} var.
## Defaults to: 'https://{bucket_name}.s3.amazonaws.com'
AWS_DEFAULT_LOCATION = "https://{bucket_name}.s3.amazonaws.com"

加载器

thumbor-aws 加载器提供多个配置选项

################################## AWS Loader ##################################

## Region where thumbor's objects are going to be loaded from.
## Defaults to: 'us-east-1'
#AWS_LOADER_REGION_NAME = 'us-east-1'

## S3 Bucket where thumbor's objects are loaded from.
## Defaults to: 'thumbor'
#AWS_LOADER_BUCKET_NAME = 'thumbor'

## Secret access key for S3 Loader.
## Defaults to: None
#AWS_LOADER_S3_SECRET_ACCESS_KEY = None

## Access key ID for S3 Loader.
## Defaults to: None
#AWS_LOADER_S3_ACCESS_KEY_ID = None

## Endpoint URL for S3 API. Very useful for testing.
## Defaults to: None
#AWS_LOADER_S3_ENDPOINT_URL = None

## Loader prefix path.
## Defaults to: '/st'
#AWS_LOADER_ROOT_PATH = '/st'

################################################################################

存储

以下是在导入 thumbor-aws 后运行 thumbor 配置生成结果的示例

################################# AWS Storage ##################################

## Region where thumbor's objects are going to be stored.
## Defaults to: 'us-east-1'
#AWS_STORAGE_REGION_NAME = 'us-east-1'

## S3 Bucket where thumbor's objects are going to be stored.
## Defaults to: 'thumbor'
#AWS_STORAGE_BUCKET_NAME = 'thumbor'

## Secret access key for S3 to allow thumbor to store objects there.
## Defaults to: None
#AWS_STORAGE_S3_SECRET_ACCESS_KEY = None

## Access key ID for S3 to allow thumbor to store objects there.
## Defaults to: None
#AWS_STORAGE_S3_ACCESS_KEY_ID = None

## Endpoint URL for S3 API. Very useful for testing.
## Defaults to: None
#AWS_STORAGE_S3_ENDPOINT_URL = None

## Storage prefix path.
## Defaults to: '/st'
#AWS_STORAGE_ROOT_PATH = '/st'

## Storage ACL for files written in bucket
## Defaults to: 'public-read'
#AWS_STORAGE_S3_ACL = 'public-read'

## Default location to use if S3 does not return location header. Can use
## {bucket_name} var.
## Defaults to: 'https://{bucket_name}.s3.amazonaws.com'
#AWS_DEFAULT_LOCATION = 'https://{bucket_name}.s3.amazonaws.com'

################################################################################

结果存储

以下是在导入 thumbor-aws 后运行 thumbor 配置生成结果的示例

############################## AWS Result Storage ##############################

## Region where thumbor's objects are going to be stored.
## Defaults to: 'us-east-1'
#AWS_RESULT_STORAGE_REGION_NAME = 'us-east-1'

## S3 Bucket where thumbor's objects are going to be stored.
## Defaults to: 'thumbor'
#AWS_RESULT_STORAGE_BUCKET_NAME = 'thumbor'

## Secret access key for S3 to allow thumbor to store objects there.
## Defaults to: None
#AWS_RESULT_STORAGE_S3_SECRET_ACCESS_KEY = None

## Access key ID for S3 to allow thumbor to store objects there.
## Defaults to: None
#AWS_RESULT_STORAGE_S3_ACCESS_KEY_ID = None

## Endpoint URL for S3 API. Very useful for testing.
## Defaults to: None
#AWS_RESULT_STORAGE_S3_ENDPOINT_URL = None

## Result Storage prefix path.
## Defaults to: '/rs'
#AWS_RESULT_STORAGE_ROOT_PATH = '/rs'

## ACL to use for storing items in S3.
## Defaults to: None
#AWS_RESULT_STORAGE_S3_ACL = None

################################################################################

以兼容模式配置 thumbor 与 tc_aws

如果您是 tc_aws 用户,thumbor-aws 具有兼容模式,您可以使用您已经熟悉的相同配置

############################# tc_aws Compatibility #############################

## Runs in compatibility mode using the configurations for tc_aws.
## Defaults to: False
THUMBOR_AWS_RUN_IN_COMPATIBILITY_MODE = True

## AWS Region the bucket is located in.
## Defaults to: 'us-east-1'
TC_AWS_REGION = 'us-east-1'

## Max retries for get image from S3 Bucket. Default is 0
## Defaults to: 0
TC_AWS_MAX_RETRY = 0  # This is not yet supported

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

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

## S3 bucket for Storage
## Defaults to: ''
TC_AWS_STORAGE_BUCKET = 'my-bucket'

## S3 path prefix for Storage bucket
## Defaults to: ''
TC_AWS_STORAGE_ROOT_PATH = 'source-files'

## 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/
## Defaults to: False
TC_AWS_STORAGE_SSE = False  # This is not yet supported

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

## S3 bucket for result Storage
## Defaults to: ''
TC_AWS_RESULT_STORAGE_BUCKET = 'my-bucket'

## S3 path prefix for Result storage bucket
## Defaults to: ''
TC_AWS_RESULT_STORAGE_ROOT_PATH = 'result-storage'

## Store result with metadata (for instance content-type)
## Defaults to: False
# This configuration won't matter as thumbor-aws stores metadata anyway
TC_AWS_STORE_METADATA = False

################################################################################

请注意,添加 THUMBOR_AWS_RUN_IN_COMPATIBILITY_MODE = True 以告知 thumbor_aws 您想要与 tc_aws 兼容。

如果您有任何问题

注意事项

  1. thumbor-aws 不会为您创建存储桶。如果它们不存在,您将收到错误。

您可以使用 aws-cli 轻松创建存储桶

$ aws s3api create-bucket --bucket <bucket name> --region <your region>

或者通过您的 AWS 控制台 UI

遇到麻烦了吗?

如果您遇到任何问题,请尝试运行

thumbor-doctor

如果您仍然需要帮助,请 提交问题

👀 Thumbor

thumbor-aws 建立在 Thumbor 之上!如果您不熟悉 Thumbor,请查看 文档 或在 http://thumborize.me/ 上查看演示。

👍 贡献

thumbor-aws 是一个开源项目,拥有许多贡献者。加入他们 贡献代码贡献文档

加入聊天 https://gitter.im/thumbor/thumbor

许可证

MIT 许可证

版权所有 (c) 2021 thumbor-aws (由 @heynemann)

特此免费授予任何获得本软件及其相关文档文件(“软件”)副本的任何人(以下简称“用户”)在本软件上不受限制地处理软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许向用户提供软件的人这样做,前提是用户同意以下条件

上述版权声明和本许可声明应包含在本软件的所有副本或主要部分中。

本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论此类索赔、损害或其他责任是基于合同、侵权或其他原因,以及与软件或其使用或其他方式有关。

项目详情


下载文件

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

源代码发行版

thumbor_aws-0.8.0.tar.gz (13.1 kB 查看哈希)

上传于 来源

构建的发行版

thumbor_aws-0.8.0-py3-none-any.whl (14.4 kB 查看哈希值)

上传于 Python 3

由以下支持