convergine / craft-sharebox
ShareBox 允许您将托管在 Azure Blob Storage 或 Amazon S3 上的文件与您的网站访客共享。
Requires
- aws/aws-sdk-php: ^3.234.2
- craftcms/cms: ^4.0.0 || ^5.0.0
- microsoft/azure-storage-blob: ^1.5.3
This package is auto-updated.
Last update: 2024-09-21 23:23:03 UTC
README
ShareBox 是 CraftCMS v4.x 的文件管理插件,允许您在前端将 Azure Blob Storage 或 Amazon S3 上的文件上传和共享给您的网站访客。
为了使插件工作,需要一个 Amazon S3 ( https://aws.amazon.com/s3/ ) 或 Azure Blob Storage ( https://azure.microsoft.com/en-us/products/storage/blobs ) 账户,并必须创建 Azure Blob Storage API 密钥 https://learn.microsoft.com/en-us/rest/api/storageservices/blob-service-rest-api。
注意:插件只与连接到您的 Azure/Amazon 实例后创建的文件和文件夹一起工作。它无法显示您 Azure/Amazon 账户上已存在的文件或文件夹。只有通过插件创建的文件/文件夹将在目录视图中显示)
功能
- AWS 集成:轻松将文件上传到 Amazon S3 并在网站前端“目录视图”中共享
- Microsoft Azure 集成:轻松将文件上传到 Azure Blob Storage 并在网站前端“目录视图”中共享
- 在首页上对文件目录视图进行密码保护(可选)
- 目录视图的 Google ReCaptcha 集成
- 简单的下载统计信息
要求
- 此插件需要 Azure Blob Storage 或 Amazon S3 账户才能工作
- Craft CMS 4.0.0 或更高版本
- PHP 8.0.2 或更高版本
安装
- 您可以从 Plugin Store 或使用 Composer 安装此插件
# installation with composer # 1. go to the project directory cd /path/to/my-project # 2. tell Composer to load the plugin composer require convergine/craft-sharebox # 3. tell Craft to install the plugin ./craft plugin/install craft-sharebox
- 在 CraftCMS 控制面板中激活插件(如果尚未激活)
- 编辑您的 .env 文件并添加以下变量
# for Azure Blob Storage
SHAREBOX_PROVIDER=AZUREBLOB
# edit the following variables with your own values
AZURE_BLOB_STORAGE_KEY1=your_key
AZURE_BLOB_STORAGE_ACCOUNT_NAME=accountname
AZURE_CONTAINER=container
或者
# for Amazon S3
SHAREBOX_PROVIDER=AMAZONS3
# edit the following variables with your own values
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=ca-central-1
AWS_BUCKET=your_bucket
- 在 CraftCMS 控制面板的插件菜单中配置设置
转到 ShareBox 设置并输入您将用于显示文件共享的页面的完整 URL 例如 https://www.yourdomain.com/files-directory
- 调整 twig 模板以显示 ShareBox
# register the asset bundle (somewhere at the top of the file)
{% do view.registerAssetBundle("convergine\\sharebox\\assets\\FilesAssets") %}
# add the following code where you want the directory to show up
{% set files = craft.azurefiles.files%}
{{ files|raw }}
- 现在您可以使用 CraftCMS 控制面板中的插件界面上传文件。
注意:如果您在通过插件界面创建文件夹和上传文件后决定在 Azure/Amazon 之间切换,您需要在提供商切换后重新通过插件上传所有内容,因为插件会将新提供商的容器视为完全为空。
自定义设计
目前,调整前端目录视图设计的方法是:要么使用 !important
属性添加与 Sharebox 前端.css 中相同的样式,要么在放置 Sharebox twig 代码的模板中添加调整后的样式。直接在插件文件中编辑样式会在插件更新时覆盖更改。
支持
对于任何问题或疑问,您可以通过电子邮件 info@convergine.com 或在 GitHub 上打开一个问题来联系我们。
路线图
- 支持本地文件存储
- 改进的统计信息