文件上传

This commit is contained in:
2025-03-19 15:22:45 +08:00
parent e2fd96ea26
commit 6169be08e5
6 changed files with 618 additions and 36 deletions
+36
View File
@@ -7,6 +7,8 @@ namespace app\controller;
//use Webman\Http\Response;
use app\util\Util;
use app\service\OssService;
use Shopwwi\WebmanFilesystem\Facade\Storage;
use support\Log;
use support\Request;
@@ -95,4 +97,38 @@ class UploadController
return Util::fail([],$e->getMessage());
}
}
// 上传单文件图片
public function uploadImage(Request $request)
{
try {
$file = $request->file('files');
if (!$file || !$file->isValid()) {
return Util::fail($file,'上传失败');
}
$result = Storage::adapter('oss')
->path('vehicle_album/'.date('Ymd'))
->size(1024*1024*5)
->extYes(['image/jpeg','image/png'])
->extNo(['image/gif'])
->upload($file);
$ossservice = new OssService();
$data = [
'image_name' => $result->file_name,
'image_url' => $ossservice->generatePrivateUrl($result->file_name)
];
return Util::success($data,'上传成功');
}catch (\Throwable $e){
Log::error('文件上传失败: ' . $e->getMessage());
return Util::fail([],'file:'.$e->getFile().'line:'.$e->getLine().'message:'.$e->getMessage());
}
}
}
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace app\service;
use OSS\OssClient;
use OSS\Core\OssException;
class OssService
{
private $accessKeyId;
private $accessKeySecret;
private $bucket;
private $endpoint;
private $ossClient;
public function __construct()
{
$this->accessKeyId = 'LTAI5tAGiH7bkVkmrniXnfkA';
$this->accessKeySecret = 'nqklJBft6t3S0A4ZvxF4ci9ni91kmm';
$this->bucket = 'vehicle-album';
$this->endpoint = 'https://oss-cn-beijing.aliyuncs.com';
$this->ossClient = new OssClient($this->accessKeyId, $this->accessKeySecret, $this->endpoint);
}
/**
* 上传图片到 OSS
* @param string $filePath 本地文件路径
* @param string $objectKey OSS上存储的对象名称
* @return string 图片的 URL
*/
public function uploadImage($filePath, $objectKey)
{
try {
// 上传文件到 OSS
$this->ossClient->uploadFile($this->bucket, $objectKey, $filePath);
// 构造图片的私有 URL
$url = $this->generatePrivateUrl($objectKey);
return $url;
} catch (OssException $e) {
// 错误处理
throw new \RuntimeException('OSS Error: ' . $e->getMessage());
}
}
/**
* 生成图片的私有访问 URL
* @param string $objectKey
* @return string
*/
public function generatePrivateUrl($objectKey, $expireTime = 3600)
{
// 生成 OSS 私有 URL(有效期为 3600 秒)
return $this->ossClient->signUrl($this->bucket, $objectKey, $expireTime);
}
}
+3 -1
View File
@@ -35,7 +35,9 @@
"symfony/translation": "^7.2",
"firebase/php-jwt": "^6.11",
"illuminate/database": "^11.44",
"phpmailer/phpmailer": "^6.9"
"phpmailer/phpmailer": "^6.9",
"shopwwi/webman-filesystem": "^2.0",
"iidestiny/flysystem-oss": "4.5"
},
"suggest": {
"ext-event": "For better performance. "
Generated
+412 -34
View File
@@ -4,8 +4,59 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "55d46d79b19fab3d24ee06892f254c93",
"content-hash": "ae2f4f7e2fab33fd2510f9f789bf1dc1",
"packages": [
{
"name": "aliyuncs/oss-sdk-php",
"version": "v2.7.2",
"source": {
"type": "git",
"url": "https://github.com/aliyun/aliyun-oss-php-sdk.git",
"reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5",
"reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"php-coveralls/php-coveralls": "*",
"phpunit/phpunit": "*"
},
"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/",
"support": {
"issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues",
"source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.7.2"
},
"time": "2024-10-28T10:41:12+00:00"
},
{
"name": "brick/math",
"version": "0.12.3",
@@ -289,9 +340,71 @@
},
"time": "2025-01-23T05:11:06+00:00"
},
{
"name": "iidestiny/flysystem-oss",
"version": "4.5",
"source": {
"type": "git",
"url": "https://github.com/iiDestiny/flysystem-oss.git",
"reference": "154ccb26075a20b350e2357289bfeabe3ca79ba0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/iiDestiny/flysystem-oss/zipball/154ccb26075a20b350e2357289bfeabe3ca79ba0",
"reference": "154ccb26075a20b350e2357289bfeabe3ca79ba0",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"aliyuncs/oss-sdk-php": "^2",
"ext-curl": "*",
"ext-json": "*",
"ext-openssl": "*",
"league/flysystem": "^3.0",
"php": "^8.0.2"
},
"require-dev": {
"mockery/mockery": "^1.5",
"phpunit/phpunit": "^9.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"
],
"support": {
"issues": "https://github.com/iiDestiny/flysystem-oss/issues",
"source": "https://github.com/iiDestiny/flysystem-oss/tree/4.5"
},
"time": "2025-02-12T05:54:03+00:00"
},
{
"name": "illuminate/bus",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/bus.git",
@@ -344,16 +457,16 @@
},
{
"name": "illuminate/collections",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
"reference": "48f5357348093bc8b94c691aa3ffc861d2ecc2a0"
"reference": "f2f537dfb2a142791d37478f34c920b44a45cea9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/48f5357348093bc8b94c691aa3ffc861d2ecc2a0",
"reference": "48f5357348093bc8b94c691aa3ffc861d2ecc2a0",
"url": "https://api.github.com/repos/illuminate/collections/zipball/f2f537dfb2a142791d37478f34c920b44a45cea9",
"reference": "f2f537dfb2a142791d37478f34c920b44a45cea9",
"shasum": ""
},
"require": {
@@ -396,11 +509,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-02-28T16:55:51+00:00"
"time": "2025-03-06T14:02:47+00:00"
},
{
"name": "illuminate/conditionable",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/conditionable.git",
@@ -446,7 +559,7 @@
},
{
"name": "illuminate/container",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
@@ -497,7 +610,7 @@
},
{
"name": "illuminate/contracts",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
@@ -614,7 +727,7 @@
},
{
"name": "illuminate/events",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/events.git",
@@ -669,7 +782,7 @@
},
{
"name": "illuminate/macroable",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@@ -715,7 +828,7 @@
},
{
"name": "illuminate/pagination",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/pagination.git",
@@ -765,7 +878,7 @@
},
{
"name": "illuminate/pipeline",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/pipeline.git",
@@ -813,16 +926,16 @@
},
{
"name": "illuminate/redis",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/redis.git",
"reference": "21eb42b3d3271b3365a3685cb552b31cda1de255"
"reference": "487d745c26eee9de68b85f89691ef7752b74a398"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/redis/zipball/21eb42b3d3271b3365a3685cb552b31cda1de255",
"reference": "21eb42b3d3271b3365a3685cb552b31cda1de255",
"url": "https://api.github.com/repos/illuminate/redis/zipball/487d745c26eee9de68b85f89691ef7752b74a398",
"reference": "487d745c26eee9de68b85f89691ef7752b74a398",
"shasum": ""
},
"require": {
@@ -863,11 +976,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2025-02-17T15:53:37+00:00"
"time": "2025-03-07T15:42:48+00:00"
},
{
"name": "illuminate/support",
"version": "v11.44.1",
"version": "v11.44.2",
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
@@ -1003,6 +1116,212 @@
},
"time": "2025-02-11T15:03:05+00:00"
},
{
"name": "league/flysystem",
"version": "3.29.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "0adc0d9a51852e170e0028a60bd271726626d3f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/0adc0d9a51852e170e0028a60bd271726626d3f0",
"reference": "0adc0d9a51852e170e0028a60bd271726626d3f0",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"league/flysystem-local": "^3.0.0",
"league/mime-type-detection": "^1.0.0",
"php": "^8.0.2"
},
"conflict": {
"async-aws/core": "<1.19.0",
"async-aws/s3": "<1.14.0",
"aws/aws-sdk-php": "3.209.31 || 3.210.0",
"guzzlehttp/guzzle": "<7.0",
"guzzlehttp/ringphp": "<1.1.1",
"phpseclib/phpseclib": "3.0.15",
"symfony/http-client": "<5.2"
},
"require-dev": {
"async-aws/s3": "^1.5 || ^2.0",
"async-aws/simple-s3": "^1.1 || ^2.0",
"aws/aws-sdk-php": "^3.295.10",
"composer/semver": "^3.0",
"ext-fileinfo": "*",
"ext-ftp": "*",
"ext-mongodb": "^1.3",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.5",
"google/cloud-storage": "^1.23",
"guzzlehttp/psr7": "^2.6",
"microsoft/azure-storage-blob": "^1.1",
"mongodb/mongodb": "^1.2",
"phpseclib/phpseclib": "^3.0.36",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.5.11|^10.0",
"sabre/dav": "^4.6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\Flysystem\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frankdejonge.nl"
}
],
"description": "File storage abstraction for PHP",
"keywords": [
"WebDAV",
"aws",
"cloud",
"file",
"files",
"filesystem",
"filesystems",
"ftp",
"s3",
"sftp",
"storage"
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/3.29.0"
},
"time": "2024-09-29T11:59:11+00:00"
},
{
"name": "league/flysystem-local",
"version": "3.29.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem-local.git",
"reference": "e0e8d52ce4b2ed154148453d321e97c8e931bd27"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem-local/zipball/e0e8d52ce4b2ed154148453d321e97c8e931bd27",
"reference": "e0e8d52ce4b2ed154148453d321e97c8e931bd27",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-fileinfo": "*",
"league/flysystem": "^3.0.0",
"league/mime-type-detection": "^1.0.0",
"php": "^8.0.2"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\Flysystem\\Local\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frankdejonge.nl"
}
],
"description": "Local filesystem adapter for Flysystem.",
"keywords": [
"Flysystem",
"file",
"files",
"filesystem",
"local"
],
"support": {
"source": "https://github.com/thephpleague/flysystem-local/tree/3.29.0"
},
"time": "2024-08-09T21:24:39+00:00"
},
{
"name": "league/mime-type-detection",
"version": "1.15.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/mime-type-detection.git",
"reference": "ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301",
"reference": "ce0f4d1e8a6f4eb0ddff33f57c69c50fd09f4301",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-fileinfo": "*",
"php": "^7.4 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.2",
"phpstan/phpstan": "^0.12.68",
"phpunit/phpunit": "^8.5.8 || ^9.3 || ^10.0"
},
"type": "library",
"autoload": {
"psr-4": {
"League\\MimeTypeDetection\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Frank de Jonge",
"email": "info@frankdejonge.nl"
}
],
"description": "Mime-type detection for Flysystem",
"support": {
"issues": "https://github.com/thephpleague/mime-type-detection/issues",
"source": "https://github.com/thephpleague/mime-type-detection/tree/1.15.0"
},
"funding": [
{
"url": "https://github.com/frankdejonge",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/league/flysystem",
"type": "tidelift"
}
],
"time": "2024-01-28T23:22:08+00:00"
},
{
"name": "monolog/monolog",
"version": "2.10.0",
@@ -1544,6 +1863,65 @@
},
"time": "2021-10-29T13:26:27+00:00"
},
{
"name": "shopwwi/webman-filesystem",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/shopwwi/webman-filesystem.git",
"reference": "de33afdbfc56678323f1aafb8d011d79378d164a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/shopwwi/webman-filesystem/zipball/de33afdbfc56678323f1aafb8d011d79378d164a",
"reference": "de33afdbfc56678323f1aafb8d011d79378d164a",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"league/flysystem": "^2.3|^3.0",
"php": ">=7.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Shopwwi\\WebmanFilesystem\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Tycoon Song",
"email": "8988354@qq.com"
}
],
"description": "Flysystem V2 adapter for the webman",
"keywords": [
"cos",
"filesystem",
"oss",
"qiniu",
"webman"
],
"support": {
"issues": "https://github.com/shopwwi/webman-filesystem/issues",
"source": "https://github.com/shopwwi/webman-filesystem/tree/v2.0.0"
},
"time": "2025-03-17T11:14:43+00:00"
},
{
"name": "symfony/clock",
"version": "v7.2.0",
@@ -2173,20 +2551,20 @@
},
{
"name": "webman/database",
"version": "v2.1.4",
"version": "v2.1.5",
"source": {
"type": "git",
"url": "https://github.com/webman-php/database.git",
"reference": "985701df423a71f796b6fb87d3b3afcd1856d3bb"
"reference": "df874826b63e8f16dd0d04e6228f873b1ce22739"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webman-php/database/zipball/985701df423a71f796b6fb87d3b3afcd1856d3bb",
"reference": "985701df423a71f796b6fb87d3b3afcd1856d3bb",
"url": "https://api.github.com/repos/webman-php/database/zipball/df874826b63e8f16dd0d04e6228f873b1ce22739",
"reference": "df874826b63e8f16dd0d04e6228f873b1ce22739",
"shasum": ""
},
"require": {
"illuminate/database": "^10.0 || ^11.0",
"illuminate/database": "^10.0 || ^11.0 || ^12.0",
"laravel/serializable-closure": "^1.0 || ^2.0",
"workerman/webman-framework": "^2.1 || dev-master"
},
@@ -2204,26 +2582,26 @@
"description": "Webman database",
"support": {
"issues": "https://github.com/webman-php/database/issues",
"source": "https://github.com/webman-php/database/tree/v2.1.4"
"source": "https://github.com/webman-php/database/tree/v2.1.5"
},
"time": "2025-02-24T07:14:57+00:00"
"time": "2025-03-14T03:41:33+00:00"
},
{
"name": "webman/redis",
"version": "v2.1.2",
"version": "v2.1.3",
"source": {
"type": "git",
"url": "https://github.com/webman-php/redis.git",
"reference": "83893f0931e07906ba9dbf976126ad8338f40624"
"reference": "559eb1692d39c6fef5cf526223fff728be6c0fb9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webman-php/redis/zipball/83893f0931e07906ba9dbf976126ad8338f40624",
"reference": "83893f0931e07906ba9dbf976126ad8338f40624",
"url": "https://api.github.com/repos/webman-php/redis/zipball/559eb1692d39c6fef5cf526223fff728be6c0fb9",
"reference": "559eb1692d39c6fef5cf526223fff728be6c0fb9",
"shasum": ""
},
"require": {
"illuminate/redis": "^10.0 || ^11.0",
"illuminate/redis": "^10.0 || ^11.0 || ^12.0",
"workerman/webman-framework": "^2.1 || dev-master"
},
"type": "library",
@@ -2240,9 +2618,9 @@
"description": "Webman redis",
"support": {
"issues": "https://github.com/webman-php/redis/issues",
"source": "https://github.com/webman-php/redis/tree/v2.1.2"
"source": "https://github.com/webman-php/redis/tree/v2.1.3"
},
"time": "2025-02-14T11:36:24+00:00"
"time": "2025-03-14T03:52:14+00:00"
},
{
"name": "workerman/coroutine",
+110
View File
@@ -0,0 +1,110 @@
<?php
return [
'enable' => true,
'default' => 'local',
'max_size' => 1024 * 1024 * 10, //单个文件大小10M
'ext_yes' => [], //允许上传文件类型 为空则为允许所有
'ext_no' => [], // 不允许上传文件类型 为空则不限制
'storage' => [
'public' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\LocalAdapterFactory::class,
'root' => public_path(),
'url' => '//127.0.0.1:8787' // 静态文件访问域名
],
'local' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\LocalAdapterFactory::class,
'root' => runtime_path(),
'url' => '//127.0.0.1:8787' // 静态文件访问域名
],
'ftp' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\FtpAdapterFactory::class,
'host' => 'ftp.example.com',
'username' => 'username',
'password' => 'password',
'url' => '' // 静态文件访问域名
// 'port' => 21,
// 'root' => '/path/to/root',
// 'passive' => true,
// 'ssl' => true,
// 'timeout' => 30,
// 'ignorePassiveAddress' => false,
// 'timestampsOnUnixListingsEnabled' => true,
],
'memory' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\MemoryAdapterFactory::class,
],
's3' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\S3AdapterFactory::class,
'credentials' => [
'key' => 'S3_KEY',
'secret' => 'S3_SECRET',
],
'region' => 'S3_REGION',
'version' => 'latest',
'bucket_endpoint' => false,
'use_path_style_endpoint' => false,
'endpoint' => 'S3_ENDPOINT',
'bucket_name' => 'S3_BUCKET',
'url' => '' // 静态文件访问域名
],
'minio' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\S3AdapterFactory::class,
'credentials' => [
'key' => 'S3_KEY',
'secret' => 'S3_SECRET',
],
'region' => 'S3_REGION',
'version' => 'latest',
'bucket_endpoint' => false,
'use_path_style_endpoint' => true,
'endpoint' => 'S3_ENDPOINT',
'bucket_name' => 'S3_BUCKET',
'url' => '' // 静态文件访问域名
],
'oss' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\AliyunOssAdapterFactory::class,
// 'accessId' => 'OSS_ACCESS_ID',
// 'accessSecret' => 'OSS_ACCESS_SECRET',
// 'bucket' => 'OSS_BUCKET',
// 'endpoint' => 'OSS_ENDPOINT',
// 'url' => '', // 静态文件访问域名
'accessKey' => 'LTAI5tAGiH7bkVkmrniXnfkA',
'secretKey' => 'nqklJBft6t3S0A4ZvxF4ci9ni91kmm',
'bucket' => 'vehicle-album',
'endpoint' => 'https://oss-cn-beijing.aliyuncs.com',
'url' => 'https://vehicle-album.oss-cn-beijing.aliyuncs.com', // 静态文件访问域名
// 'timeout' => 3600,
// 'connectTimeout' => 10,
'isCName' => false,
'prefix' => '',
// 'token' => null,
// 'proxy' => null,
],
'qiniu' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\QiniuAdapterFactory::class,
'accessKey' => 'QINIU_ACCESS_KEY',
'secretKey' => 'QINIU_SECRET_KEY',
'bucket' => 'QINIU_BUCKET',
'domain' => 'QINBIU_DOMAIN',
'url' => '' // 静态文件访问域名
],
'cos' => [
'driver' => \Shopwwi\WebmanFilesystem\Adapter\CosAdapterFactory::class,
'region' => 'COS_REGION',
'app_id' => 'COS_APPID',
'secret_id' => 'COS_SECRET_ID',
'secret_key' => 'COS_SECRET_KEY',
// 可选,如果 bucket 为私有访问请打开此项
// 'signed_url' => false,
'bucket' => 'COS_BUCKET',
'read_from_cdn' => false,
'url' => '' // 静态文件访问域名
// 'timeout' => 60,
// 'connect_timeout' => 60,
// 'cdn' => '',
// 'scheme' => 'https',
],
],
];
+2 -1
View File
@@ -24,7 +24,8 @@ use Webman\Route;
Route::any('/login', [app\controller\UserController::class, 'login'])->middleware([app\middleware\CrossDomain::class]);
// 文件上传接口
Route::post('/upload', [app\controller\UploadController::class, 'upload']);
Route::post('/upload', [app\controller\UploadController::class, 'uploadImage']);