whiterabbit/s3file-manager

There is no license information available for the latest version (3.0.68) of this package.

S3FileManager plugin for CakePHP

Installs: 426

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 6

Forks: 0

Open Issues: 1

Language:JavaScript

Type:cakephp-plugin

3.0.68 2019-06-13 10:18 UTC

README

Installation

You can install the plugin cackephp-utils into your CakePHP application using composer and executing the following lines in the root of your application.

composer require whiterabbit/s3file-manager=dev-master

bin\cake migrations migrate -p S3FileManager

Configuration

You will need to add the following line to your application's bootstrap.php file:

Plugin::load('S3FileManager');

And in your AppController add

use S3FileManager\Controller\WRTrait;

class AppController extends Controller
{
    use WRTrait;
}

In order to pass a customer name / site to the UploadableBehavior you have to put it in the parameter session Auth.User.fc_customer_site (ie in AppController, beforeFilter method):

 public function beforeFilter(Event $event)
 {
   $this->request->session()->write('Auth.User.fc_customer_site', 'my.customer.site');

 } 

For the S3File Helper, in your AppController add

public function initialize() {
    $this->helpers[] = 'S3FileManager.S3File';
}

To access Amazon resources, this plugin need the Aws SDK installed. You can download the v3 version of the SDK from here http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/installation.html and follow instruction under the section "Installing via Zip" (in general this mean to copy the aws folder under /src/Lib of your project)

In the page where you would to add the file browser:

<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(); ?>

version

1.2.0

  • AAA

1.1.0

  • Added Files -> uploadFileToResizeFolder($base64ImageData, $imgName)
  • Optimized code

1.0.2

  • Solved some bug

1.0.1

  • Composer refactoring

1.0.0

  • Refactoring some piece of code
  • Creating an handy plugin

0.2.1

  • S3FileHelper: Set the default image instead of an html code
  • Added a customer site name to the uploadable behavior in order to create, in S3, separate bucket for different customers.
    if you want use this feature add the parameter Auth.User.fc_customer_site in your session

0.1.3.1 Solved sum bug on S3FileHelper

0.1.3 Added S3FileHelper helper

0.1.2 Added folder management for S3

0.1.1 Initial release

License

The MIT License (MIT)

Copyright (c) 2016 WhiteRabbit by Dino Fratelli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.