whiterabbit/s3file-manager

此包的最新版本(3.0.68)没有提供许可证信息。

S3FileManager插件用于CakePHP

安装: 426

依赖: 0

建议: 0

安全: 0

星标: 0

关注者: 6

分支: 0

开放问题: 1

语言:JavaScript

类型:cakephp-plugin

3.0.68 2019-06-13 10:18 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

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

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

本软件按“原样”提供,不提供任何形式的保证,无论是明示的还是隐含的,包括但不限于对适销性、特定用途的适用性和非侵权的保证。在任何情况下,作者或版权持有人不对任何索赔、损害或其他责任承担责任,无论这些责任是否源于合同行为、侵权或其他方式,以及与软件或对软件的使用或其他使用相关的任何事件。