Package Data | |
---|---|
Maintainer Username: | demon823 |
Maintainer Contact: | hui.liu@timelink.cn (Kify) |
Package Create Date: | 2016-06-21 |
Package Last Update: | 2017-03-27 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 15:02:20 |
Package Statistics | |
---|---|
Total Downloads: | 69 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Package for laravle 5.* to deal with S3 rest api upload
To use 1、composer require eunion/s3
2、Add the package to your application service providers in config/app.php file.
'providers' => [
/**
* Third Party Service Providers...
*/
Eunion\S3\S3ServiceProvider::class,
],
3、publish the config to app/config/s3.php
php artisan vendor:publish --provider="Eunion\S3\S3ServiceProvider" --tag=config
4、config you s3 in app/config/s3.php
return [
'driver' => 's3', //
'accessKey' => '', //your s3 api accessKey
'secret' => '', //your s3 api secret
'bucket' => '' //your s3 bucket
];
Controller Example: $s3 = new S3(); $bucket = 'kify'; $path = 'test/'; // Can be empty '' $lifetime = 3600; // Period for which the parameters are valid $maxFileSize = (1024 * 1024 * 50); // 50 MB $metaHeaders = []; $requestHeaders = array( 'Content-Type' => 'application/octet-stream', 'Content-Disposition' => 'attachment; filename=${filename}' );
$params = $s3->getHttpUploadPostParams( $bucket, $path, S3::ACL_PUBLIC_READ, $lifetime, $maxFileSize, "http://fenke.timelink.cn/test.php", // Or a URL to redirect to on success $metaHeaders, $requestHeaders, false // False since we're not using flash );
$uploadUrl = "https://{$bucket}.".$s3::$endpoint;
return view('home.s3.index',compact('params','uploadUrl'));
Blade Example: