Browse Source

添加oss配置

master
Mike 5 years ago
parent
commit
ab813f53c1
  1. 2
      app/Admin/Controllers/LanzuServiceSpeakerController.php
  2. 28
      app/Http/Controllers/TestController.php
  3. 1
      composer.json
  4. 198
      composer.lock
  5. 2
      config/admin.php
  6. 2
      config/app.php
  7. 14
      config/filesystems.php
  8. 4
      routes/web.php

2
app/Admin/Controllers/LanzuServiceSpeakerController.php

@ -57,7 +57,7 @@ class LanzuServiceSpeakerController extends AdminController
{
return Form::make(new LanzuServiceSpeaker(), function (Form $form) {
$form->display('id');
//$form->image("device_name")->disk('oss');
$form->display('created_at');
$form->display('updated_at');
});

28
app/Http/Controllers/TestController.php

@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use App\Http\Controllers\Controller as BaseController;
use Illuminate\Support\Facades\Storage;
class TestController extends BaseController
{
public function Test(){
$ret = null;
try {
//code...
$ret = Storage::disk('oss')->put('test_file.txt', 'Contents');
} catch (\Throwable $th) {
//throw $th;
dd($th);
}
// $ret = Storage::get('test_file.txt');
dd($ret);
return 1;
}
}

1
composer.json

@ -13,6 +13,7 @@
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"iidestiny/laravel-filesystem-oss": "^2.0",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0"
},

198
composer.lock

@ -4,8 +4,55 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c21ee2ad6564653c5795b9c1b963ad17",
"content-hash": "e6c7615960e10e0e6c86b86b3a49a061",
"packages": [
{
"name": "aliyuncs/oss-sdk-php",
"version": "v2.3.1",
"source": {
"type": "git",
"url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
"reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/053d7ba9e798e4c09b9c5c1edab153d25ea9643a",
"reference": "053d7ba9e798e4c09b9c5c1edab153d25ea9643a",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"OSS\\": "src/OSS"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aliyuncs",
"homepage": "http://www.aliyun.com"
}
],
"description": "Aliyun OSS SDK for PHP",
"homepage": "http://www.aliyun.com/product/oss/",
"time": "2019-11-15T11:05:42+00:00"
},
{
"name": "asm89/stack-cors",
"version": "1.3.0",
@ -417,16 +464,16 @@
},
{
"name": "doctrine/event-manager",
"version": "1.1.0",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/event-manager.git",
"reference": "629572819973f13486371cb611386eb17851e85c"
"reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/629572819973f13486371cb611386eb17851e85c",
"reference": "629572819973f13486371cb611386eb17851e85c",
"url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f",
"reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f",
"shasum": "",
"mirrors": [
{
@ -436,7 +483,7 @@
]
},
"require": {
"php": "^7.1"
"php": "^7.1 || ^8.0"
},
"conflict": {
"doctrine/common": "<2.9@dev"
@ -495,7 +542,7 @@
"event system",
"events"
],
"time": "2019-11-10T09:48:07+00:00"
"time": "2020-05-29T18:28:51+00:00"
},
{
"name": "doctrine/inflector",
@ -1113,6 +1160,115 @@
],
"time": "2019-07-01T23:21:34+00:00"
},
{
"name": "iidestiny/flysystem-oss",
"version": "2.3",
"source": {
"type": "git",
"url": "https://github.com/iiDestiny/flysystem-oss.git",
"reference": "066dfa477d92a9d248722ac660953f467c35a4aa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/iiDestiny/flysystem-oss/zipball/066dfa477d92a9d248722ac660953f467c35a4aa",
"reference": "066dfa477d92a9d248722ac660953f467c35a4aa",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"aliyuncs/oss-sdk-php": "^2.3",
"ext-curl": "*",
"ext-json": "*",
"ext-openssl": "*",
"league/flysystem": "^1.0",
"nesbot/carbon": "^1.24.1 || ^2.0",
"php": "^7.0"
},
"require-dev": {
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^6.5",
"symfony/var-dumper": "^3.4"
},
"type": "library",
"autoload": {
"psr-4": {
"Iidestiny\\Flysystem\\Oss\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "iidestiny",
"email": "iidestiny@vip.qq.com"
}
],
"description": "Flysystem adapter for the Oss storage.",
"keywords": [
"alioss",
"laravel",
"oss",
"阿里oss"
],
"time": "2020-07-08T03:16:46+00:00"
},
{
"name": "iidestiny/laravel-filesystem-oss",
"version": "2.0",
"source": {
"type": "git",
"url": "https://github.com/iiDestiny/laravel-filesystem-oss.git",
"reference": "88dd8dadd564cd234ba6264f91505e55692013ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/iiDestiny/laravel-filesystem-oss/zipball/88dd8dadd564cd234ba6264f91505e55692013ec",
"reference": "88dd8dadd564cd234ba6264f91505e55692013ec",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"iidestiny/flysystem-oss": "~2.0",
"php": "^7.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Iidestiny\\LaravelFilesystemOss\\OssStorageServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Iidestiny\\LaravelFilesystemOss\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "iidestiny",
"email": "iidestiny@vip.qq.com"
}
],
"description": "Oss storage filesystem for Laravel.",
"time": "2020-03-28T15:21:51+00:00"
},
{
"name": "laravel/framework",
"version": "v7.22.4",
@ -3368,7 +3524,7 @@
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
@ -3436,7 +3592,7 @@
},
{
"name": "symfony/polyfill-iconv",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-iconv.git",
@ -3505,7 +3661,7 @@
},
{
"name": "symfony/polyfill-intl-grapheme",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-grapheme.git",
@ -3575,16 +3731,16 @@
},
{
"name": "symfony/polyfill-intl-idn",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
"reference": "bc6549d068d0160e0f10f7a5a23c7d1406b95ebe"
"reference": "5dcab1bc7146cf8c1beaa4502a3d9be344334251"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/bc6549d068d0160e0f10f7a5a23c7d1406b95ebe",
"reference": "bc6549d068d0160e0f10f7a5a23c7d1406b95ebe",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/5dcab1bc7146cf8c1beaa4502a3d9be344334251",
"reference": "5dcab1bc7146cf8c1beaa4502a3d9be344334251",
"shasum": "",
"mirrors": [
{
@ -3648,11 +3804,11 @@
"portable",
"shim"
],
"time": "2020-07-14T12:35:20+00:00"
"time": "2020-08-04T06:02:08+00:00"
},
{
"name": "symfony/polyfill-intl-normalizer",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-normalizer.git",
@ -3725,7 +3881,7 @@
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
@ -3794,7 +3950,7 @@
},
{
"name": "symfony/polyfill-php70",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php70.git",
@ -3863,7 +4019,7 @@
},
{
"name": "symfony/polyfill-php72",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
@ -3928,7 +4084,7 @@
},
{
"name": "symfony/polyfill-php73",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
@ -3996,7 +4152,7 @@
},
{
"name": "symfony/polyfill-php80",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",

2
config/admin.php

@ -221,7 +221,7 @@ return [
'upload' => [
// Disk in `config/filesystem.php`.
'disk' => 'public',
'disk' => 'oss',
// Image and file upload path under the disk above.
'directory' => [

2
config/app.php

@ -174,7 +174,7 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Iidestiny\LaravelFilesystemOss\OssStorageServiceProvider::class,
],
/*

14
config/filesystems.php

@ -13,7 +13,7 @@ return [
|
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),
'default' => env('FILESYSTEM_DRIVER', 'oss'),
/*
|--------------------------------------------------------------------------
@ -54,6 +54,18 @@ return [
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'oss' => [
'driver' => 'oss',
'root' => '', // 设置上传时根前缀
'access_key' => env('OSS_ACCESS_ID'),
'secret_key' => env('OSS_ACCESS_SECRET'),
'endpoint' => env('OSS_ENDPOINT'), // 使用 ssl 这里设置如: https://oss-cn-beijing.aliyuncs.com
'bucket' => env('OSS_BUCKET'),
'isCName' => env('OSS_IS_CNAME', false), // 如果 isCname 为 false,endpoint 应配置 oss 提供的域名如:`oss-cn-beijing.aliyuncs.com`,否则为自定义域名,,cname 或 cdn 请自行到阿里 oss 后台配置并绑定 bucket
// 如果有更多的 bucket 需要切换,就添加所有bucket,默认的 bucket 填写到上面,不要加到 buckets 中
'buckets'=>[
],
],
's3' => [
'driver' => 's3',

4
routes/web.php

@ -13,6 +13,4 @@ use Illuminate\Support\Facades\Route;
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/', 'TestController@Test');
Loading…
Cancel
Save