whiterabbit / s3file-manager
S3FileManager插件用于CakePHP
Requires
- php: >=5.4.16
- cakephp/cakephp: ~3.0
- components/jquery: >=2.0.0
Requires (Dev)
- dev-master
- 3.0.68
- 3.0.67
- 3.0.66
- 3.0.65
- 3.0.64
- 3.0.63
- 3.0.62
- 3.0.61
- 3.0.60
- 3.0.59
- 3.0.58
- 3.0.57
- 3.0.56
- 3.0.55
- 3.0.54
- 3.0.53
- 3.0.52
- 3.0.51
- 3.0.50
- 3.0.49
- 3.0.48
- 3.0.47
- 3.0.46
- 3.0.45
- 3.0.44
- 3.0.43
- 3.0.42
- 3.0.41
- 3.0.40
- 3.0.39
- 3.0.38
- 3.0.37
- 3.0.36
- 3.0.35
- 3.0.34
- 3.0.33
- 3.0.32
- 3.0.31
- 3.0.30
- 3.0.29
- 3.0.28
- 3.0.27
- 3.0.26
- 3.0.25
- 3.0.24
- 3.0.23
- 3.0.22
- 3.0.21
- 3.0.20
- 3.0.19
- 3.0.18
- 3.0
- dev-release/3.0.69
- dev-dependabot/npm_and_yarn/webroot/js/saribe-eModal/bootstrap-4.4.1
- dev-develop
This package is auto-updated.
Last update: 2022-10-23 13:25:39 UTC
README
安装
您可以使用composer将cackephp-utils插件安装到您的CakePHP应用程序中,并在应用程序根目录下执行以下命令。
composer require whiterabbit/s3file-manager=dev-master
bin\cake migrations migrate -p S3FileManager
配置
您需要在应用程序的bootstrap.php文件中添加以下行
Plugin::load('S3FileManager');
并在您的AppController中添加
use S3FileManager\Controller\WRTrait; class AppController extends Controller { use WRTrait; }
为了将客户名称/站点传递给UploadableBehavior,您必须在参数session Auth.User.fc_customer_site中放置它(例如,在AppController的beforeFilter方法中)
public function beforeFilter(Event $event) { $this->request->session()->write('Auth.User.fc_customer_site', 'my.customer.site'); }
对于S3File Helper,在您的AppController中添加
public function initialize() { $this->helpers[] = 'S3FileManager.S3File'; }
要访问Amazon资源,此插件需要安装Aws SDK。您可以从这里下载SDK的v3版本http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html,并遵循“通过Zip安装”部分下的说明(通常这意味着将项目/src/Lib下的aws文件夹复制到您的项目中)
在您想要添加文件浏览器的页面上
<a href="#" class="btn" class="btn btn-primary btn-lg" id="openExploreBtn">Browse</a> <?= $this->Html->script('S3FileManager.jquery-2.0.0.min.js', ['block'=>'script']) ?> <?= $this->Html->script('S3FileManager.jquery-ui/jquery-ui.min.js', ['block'=>'script']) ?> <?= $this->Html->script('S3FileManager.bootstrap.min.js', ['block'=>'script']) ?> <?= $this->Html->script('S3FileManager.saribe-eModal/dist/eModal.js', ['block'=>'script']) ?> <?php $this->Html->scriptStart(['block' => 'script']); ?> $(function(){ function exploreCallback(result) { document.getElementById('form_field_id_where_to_store_image_path_name').value = result; } var emOptions = { url: "<?= $this->Url->build(["plugin" => "S3FileManager", "controller" => "Files", "action" => "explore", "customer_site_name_used_in_S3_bucket"]); ?>", title:'Document and media manager', size: eModal.size.xl, buttons: [ {text: 'Use file(s) selected', style: 'info', id: 'myInsertButton', close: true, click: function(result){ filePath = $('#myInsertButton').attr('file-path'); // Single file - To remove in future, only for retrocompatibility files = $('#myInsertButton').attr('files'); // contains id and path of the selected files for multiple select if (filePath == null) { alert('No file selected!'); } exploreCallback(filePath); }}, {text: 'Close', style: 'danger', close: true} ] }; $('#openExploreBtn').click(function(){ eModal.ajax(emOptions).then(function(){ console.log('callback'); }); }); }); <?php $this->Html->scriptEnd(); ?>
版本
1.2.0
- AAA
1.1.0
- 添加文件 -> uploadFileToResizeFolder($base64ImageData, $imgName)
- 优化代码
1.0.2
- 修复了一些错误
1.0.1
- Composer重构
1.0.0
- 重构了一些代码片段
- 创建了一个实用的插件
0.2.1
- S3FileHelper:设置默认图像而不是HTML代码
- 为了在S3中为不同的客户创建单独的存储桶,在可上传的行为中添加了一个客户站点名称。
如果您想使用此功能,请将参数Auth.User.fc_customer_site添加到会话中
0.1.3.1 修复了S3FileHelper的一些错误
0.1.3 添加了S3FileHelper助手
0.1.2 添加了S3的文件夹管理
0.1.1 初次发布
许可证
MIT许可证(MIT)
版权所有(c)2016 WhiteRabbit by Dino Fratelli
特此授予任何人免费获得此软件及其相关文档文件(“软件”)副本的权限,无需限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本的权利,并允许向软件提供方提供软件的人这样做,但受以下条件的约束
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
本软件按“原样”提供,不提供任何形式的保证,无论是明示的还是隐含的,包括但不限于对适销性、特定用途的适用性和非侵权的保证。在任何情况下,作者或版权持有人不对任何索赔、损害或其他责任承担责任,无论这些责任是否源于合同行为、侵权或其他方式,以及与软件或对软件的使用或其他使用相关的任何事件。