feat: file upload with s3

pull/1/head
saeid_01 5 years ago
parent 0410c2dcb0
commit 6899adfbfa

@ -0,0 +1,49 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
use Storage;
class MinIOStorageServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
Storage::extend('minio', function ($app, $config) {
$client = new S3Client([
'credentials' => [
'key' => $config["key"],
'secret' => $config["secret"]
],
'region' => $config["region"],
'version' => "latest",
'bucket_endpoint' => false,
'use_path_style_endpoint' => true,
'endpoint' => $config["endpoint"],
]);
$options = [
'override_visibility_on_copy' => true
];
return new Filesystem(new AwsS3Adapter($client, $config["bucket"], '', $options));
});
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
}
}

@ -9,6 +9,7 @@
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^7.2", "php": "^7.2",
"coraxster/flysystem-aws-s3-v3-minio": "^1.0",
"fideloper/proxy": "^4.0", "fideloper/proxy": "^4.0",
"kalnoy/nestedset": "^5.0", "kalnoy/nestedset": "^5.0",
"laravel/framework": "^6.2", "laravel/framework": "^6.2",

195
composer.lock generated

@ -4,8 +4,139 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "777479d5f72d40de0d12142c590eb01f", "content-hash": "c41e87ebe57c9f47a0c594757501d667",
"packages": [ "packages": [
{
"name": "aws/aws-sdk-php",
"version": "3.134.3",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "3de2711a47e7c3f5e93a5c83f019188fd23f852f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3de2711a47e7c3f5e93a5c83f019188fd23f852f",
"reference": "3de2711a47e7c3f5e93a5c83f019188fd23f852f",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-pcre": "*",
"ext-simplexml": "*",
"guzzlehttp/guzzle": "^5.3.3|^6.2.1|^7.0",
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.4.1",
"mtdowling/jmespath.php": "^2.5",
"php": ">=5.5"
},
"require-dev": {
"andrewsville/php-token-reflection": "^1.4",
"aws/aws-php-sns-message-validator": "~1.0",
"behat/behat": "~3.0",
"doctrine/cache": "~1.4",
"ext-dom": "*",
"ext-openssl": "*",
"ext-pcntl": "*",
"ext-sockets": "*",
"nette/neon": "^2.3",
"phpunit/phpunit": "^4.8.35|^5.4.3",
"psr/cache": "^1.0",
"psr/simple-cache": "^1.0",
"sebastian/comparator": "^1.2.3"
},
"suggest": {
"aws/aws-php-sns-message-validator": "To validate incoming SNS notifications",
"doctrine/cache": "To use the DoctrineCacheAdapter",
"ext-curl": "To send requests using cURL",
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",
"ext-sockets": "To use client-side monitoring"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"psr-4": {
"Aws\\": "src/"
},
"files": [
"src/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Amazon Web Services",
"homepage": "http://aws.amazon.com"
}
],
"description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project",
"homepage": "http://aws.amazon.com/sdkforphp",
"keywords": [
"amazon",
"aws",
"cloud",
"dynamodb",
"ec2",
"glacier",
"s3",
"sdk"
],
"time": "2020-04-03T18:11:51+00:00"
},
{
"name": "coraxster/flysystem-aws-s3-v3-minio",
"version": "1.0.16",
"source": {
"type": "git",
"url": "https://github.com/coraxster/flysystem-aws-s3-v3-minio.git",
"reference": "963b771021be0eda570064a2a5051e1192c3afbd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/coraxster/flysystem-aws-s3-v3-minio/zipball/963b771021be0eda570064a2a5051e1192c3afbd",
"reference": "963b771021be0eda570064a2a5051e1192c3afbd",
"shasum": ""
},
"require": {
"aws/aws-sdk-php": "^3.0.0",
"league/flysystem": "^1.0.40",
"php": ">=5.5.0"
},
"require-dev": {
"henrikbjorn/phpspec-code-coverage": "~1.0.1",
"phpspec/phpspec": "^2.0.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"League\\Flysystem\\AwsS3v3\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frenky.net"
}
],
"description": "Flysystem adapter for the AWS S3 SDK v3.x, forked for minio support",
"time": "2017-09-26T08:08:44+00:00"
},
{ {
"name": "defuse/php-encryption", "name": "defuse/php-encryption",
"version": "v2.2.1", "version": "v2.2.1",
@ -810,6 +941,7 @@
"email": "jakub.onderka@gmail.com" "email": "jakub.onderka@gmail.com"
} }
], ],
"abandoned": "php-parallel-lint/php-console-color",
"time": "2018-09-29T17:23:10+00:00" "time": "2018-09-29T17:23:10+00:00"
}, },
{ {
@ -856,6 +988,7 @@
} }
], ],
"description": "Highlight PHP code in terminal", "description": "Highlight PHP code in terminal",
"abandoned": "php-parallel-lint/php-console-highlighter",
"time": "2018-09-29T18:48:56+00:00" "time": "2018-09-29T18:48:56+00:00"
}, },
{ {
@ -1387,6 +1520,7 @@
"markdown", "markdown",
"table" "table"
], ],
"abandoned": "league/commonmark",
"time": "2019-09-26T13:28:33+00:00" "time": "2019-09-26T13:28:33+00:00"
}, },
{ {
@ -1803,6 +1937,63 @@
], ],
"time": "2019-12-20T14:22:59+00:00" "time": "2019-12-20T14:22:59+00:00"
}, },
{
"name": "mtdowling/jmespath.php",
"version": "2.5.0",
"source": {
"type": "git",
"url": "https://github.com/jmespath/jmespath.php.git",
"reference": "52168cb9472de06979613d365c7f1ab8798be895"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/52168cb9472de06979613d365c7f1ab8798be895",
"reference": "52168cb9472de06979613d365c7f1ab8798be895",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"symfony/polyfill-mbstring": "^1.4"
},
"require-dev": {
"composer/xdebug-handler": "^1.2",
"phpunit/phpunit": "^4.8.36|^7.5.15"
},
"bin": [
"bin/jp.php"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
},
"autoload": {
"psr-4": {
"JmesPath\\": "src/"
},
"files": [
"src/JmesPath.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Declaratively specify how to extract elements from a JSON document",
"keywords": [
"json",
"jsonpath"
],
"time": "2019-12-30T18:03:34+00:00"
},
{ {
"name": "myclabs/php-enum", "name": "myclabs/php-enum",
"version": "1.7.2", "version": "1.7.2",
@ -4877,7 +5068,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "./modules/wm-reservation", "url": "./modules/wm-reservation",
"reference": "fb7569ddb3cb6ad614a2f3d68613a8f5a6a4159b" "reference": "3aa36f2cefdf73b5ecab07f62b194e3a1d03a0f8"
}, },
"require": { "require": {
"php": "^7.1.3", "php": "^7.1.3",

@ -175,6 +175,7 @@ return [
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
// App\CorePackages\Authenticate\AthenticateServiceProvider::class, // App\CorePackages\Authenticate\AthenticateServiceProvider::class,
App\Providers\MinIOStorageServiceProvider::class
], ],

@ -70,11 +70,12 @@ return [
], ],
'media' => [ 'media' => [
'driver' => 'ftp', 'driver' => 'minio',
'host' => '185.142.158.22', 'key' => env('MINIO_KEY', 'your minio server key'),
'username' => 'willacdn', 'secret' => env('MINIO_SECRET', 'your minio server secret'),
'password' => 'F9NvDsT*HVhLA@$', 'region' => 'us-east-1',
'root' => 'private_html', 'bucket' => env('MINIO_BUCKET','your minio bucket name'),
'endpoint' => env('MINIO_ENDPOINT','http://localhost:8000')
], ],
], ],

@ -29,7 +29,7 @@ return [
/* /*
* The domain that should be prepended when generating urls. * The domain that should be prepended when generating urls.
*/ */
'domain' => 'https://' . env('AWS_BUCKET') . '.s3.amazonaws.com', 'domain' => 'https://cdn.willamall.com/' . env('MINIO_BUCKET') ,
], ],
'remote' => [ 'remote' => [
@ -74,7 +74,7 @@ return [
* When urls to files get generated, this class will be called. Leave empty * When urls to files get generated, this class will be called. Leave empty
* if your files are stored locally above the site root or on s3. * if your files are stored locally above the site root or on s3.
*/ */
'url_generator' => env('MEDIA_DISK', 'media') != 'media' ? null : 'WM\Common\Services\Media\UrlGenerator\FtpUrlGenerator', 'url_generator' => env('MEDIA_DISK', 'media') != 'media' ? null : 'WM\Common\Services\Media\UrlGenerator\S3UrlGenerator',
/* /*
* Whether to activate versioning when urls to files get generated. * Whether to activate versioning when urls to files get generated.

Loading…
Cancel
Save