whiterabbit / s3file-manager
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
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
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.