跳转到主要内容

一个可以获取和存储媒体到Amazon S3的存储提供程序。

项目描述

Synapse S3存储提供程序

此模块可以用作synapse的存储提供程序,允许它从Amazon S3获取和存储媒体。

用法

在启动synapse时,s3_storage_provider.py应该在PYTHONPATH中。

synapse配置中的示例条目

media_storage_providers:
- module: s3_storage_provider.S3StorageProviderBackend
  store_local: True
  store_remote: True
  store_synchronous: True
  config:
    bucket: <S3_BUCKET_NAME>
    # All of the below options are optional, for use with non-AWS S3-like
    # services, or to specify access tokens here instead of some external method.
    region_name: <S3_REGION_NAME>
    endpoint_url: <S3_LIKE_SERVICE_ENDPOINT_URL>
    access_key_id: <S3_ACCESS_KEY_ID>
    secret_access_key: <S3_SECRET_ACCESS_KEY>

    # Server Side Encryption for Customer-provided keys
    #sse_customer_key: <S3_SSEC_KEY>
    # Your SSE-C algorithm is very likely AES256
    # Default is AES256.
    #sse_customer_algo: <S3_SSEC_ALGO>

    # The object storage class used when uploading files to the bucket.
    # Default is STANDARD.
    #storage_class: "STANDARD_IA"

    # Prefix for all media in bucket, can't be changed once media has been uploaded
    # Useful if sharing the bucket between Synapses
    # Blank if not provided
    #prefix: "prefix/to/files/in/bucket"

    # The maximum number of concurrent threads which will be used to connect
    # to S3. Each thread manages a single connection. Default is 40.
    #
    #threadpool_size: 20

此模块使用boto3,因此凭据应按以下方式指定:此处

定期清理作业

此外,在scripts/s3_media_upload中还有一个脚本,可以用作定期作业上传内容到s3,然后从本地磁盘删除。此脚本可以与存储提供程序的配置结合使用,以从s3拉取媒体,但异步上传。

安装包后,脚本应运行如下。我们建议使用tmuxscreen,因为这些在大服务器上可能需要很长时间。

database.yaml应包含传递给psycopg2以连接到您的数据库的密钥。它们可以在您的 homeserver.yaml 中的 databaseargs参数的内容中找到。

命令帮助中有更多选项。

> cd s3_media_upload
# cache.db will be created if absent. database.yaml is required to
# contain PG credentials
> ls
cache.db database.yaml
# Update cache from /path/to/media/store looking for files not used
# within 2 months
> s3_media_upload update /path/to/media/store 2m
Syncing files that haven't been accessed since: 2018-10-18 11:06:21.520602
Synced 0 new rows
100%|█████████████████████████████████████████████████████████████| 1074/1074 [00:33<00:00, 25.97files/s]
Updated 0 as deleted

> s3_media_upload upload /path/to/media/store matrix_s3_bucket_name --storage-class STANDARD_IA --delete
# prepare to wait a long time

打包和发布

对于维护者

  1. 更新setup.py中的__version__。提交。推送。
  2. 为这个版本在GitHub上创建一个发布。
  3. 发布时,一个GitHub操作工作流程将构建包并将其上传到PyPI

项目详情


下载文件

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

源代码分发

synapse_s3_storage_provider-1.5.0.tar.gz (17.2 kB 查看哈希值)

上传时间: 源代码

构建分发

synapse_s3_storage_provider-1.5.0-py3-none-any.whl (16.6 kB 查看哈希值)

上传时间: Python 3

由...