kennethormandy/craft-s3securedownloads
Composer 安装命令:
composer require kennethormandy/craft-s3securedownloads
包简介
Return an AWS signed URL and proxy the download request.
README 文档
README
This plugin will return a pre-signed URL used to allow temporary access to private objects with an expiring URL. You can optionally allow file downloads only for logged in users and force file downloads (useful for PDF files).
From the original developer, Jonathan Melville:
This plugin was originally developed for a client in the financial services industry who wanted to make sure only logged in users had access to downloads of financial reports, and download links couldn’t be shared. … Now you can keep your S3 objects private but grant temporary access to them with an expiring link.
Installation
# Require the plugin with composer
composer require kennethormandy/craft-s3securedownloads
Then, install the plugin:
# Install the plugin via the Control Panel, or by running:
./craft plugin/install s3securedownloads
Usage
Pass in an asset's entry id and it will return a pre-signed URL for that asset:
{% set asset = entry.myAssetField.one() %}
<a href="{{ getSignedUrl(asset.id) }}">{{ asset }}</a>
By default, only users logged in will be able to generate the pre-signed URL. This can be changed within the plugin settings.
The generated a pre-signed AWS S3 URL will expire after 24 hours, or however long you have configured in the plugin settings.
Options
filename
By default, the download will use the same filename as the Craft CMS asset. Alternatively, a custom filename can be passed to AWS instead. For example:
{% set asset = entry.myAssetField.one() %}
<a href="{{ getSignedUrl(asset.id, { filename: 'my-new-filename.png' }) }}">{{ asset }}</a>
Events
kennethormandy\s3securedownloads\services\SignUrlSignUrl::EVENT_BEFORE_SIGN_URLSignUrl::EVENT_AFTER_SIGN_URL
use Craft; use yii\base\Event; use kennethormandy\s3securedownloads\events\SignUrlEvent; use kennethormandy\s3securedownloads\services\SignUrl; // … Event::on( SignUrl::class, SignUrl::EVENT_BEFORE_SIGN_URL, function (SignUrlEvent $event) { $asset = $event->asset; Craft::info("Handle EVENT_BEFORE_SIGN_URL event here", __METHOD__); } ); Event::on( SignUrl::class, SignUrl::EVENT_AFTER_SIGN_URL, function (SignUrlEvent $event) { $asset = $event->asset; Craft::info("Handle EVENT_AFTER_SIGN_URL event here", __METHOD__); } );
Earlier versions
S3 Secure Downloads is available for Craft 3, 4, and 5. For a version that runs on Craft v2.5.x, see the original plugin. Note that as of June 24, 2020 all new AWS S3 buckets require URLs to be signed using Signature Version 4, and the original plugin (understandably) only signs URLs using Signature Version 2.
License
Copyright © 2016–2019 Jonathan Melville
Copyright © 2019–2024 Kenneth Ormandy Inc.
kennethormandy/craft-s3securedownloads 适用场景与选型建议
kennethormandy/craft-s3securedownloads 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.66k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2019 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「aws」 「Craft」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kennethormandy/craft-s3securedownloads 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kennethormandy/craft-s3securedownloads 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kennethormandy/craft-s3securedownloads 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
GraphQL authentication for your headless Craft CMS applications.
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
Elastic Driver for Laravel Scout
Supercharged text field validation.
simple api library.
统计信息
- 总下载量: 11.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-12-18
