Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-common
Commits
dffa08df
Commit
dffa08df
authored
Feb 23, 2023
by
Liu lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使用oss固定目录
parent
69b68780
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
UploadOssService.php
src/UploadOss/UploadOssService.php
+8
-5
No files found.
src/UploadOss/UploadOssService.php
View file @
dffa08df
...
@@ -179,18 +179,21 @@ class UploadOssService
...
@@ -179,18 +179,21 @@ class UploadOssService
* 上传本地文件到oss
* 上传本地文件到oss
* @param string $localFilePath
* @param string $localFilePath
* @param string $ossFilePath 枚举key
* @param string $ossFilePath 枚举key
* @param bool $fixedDir 使用oss固定目录
* @return mixed
* @return mixed
* @throws HttpResponseException
* @throws HttpResponseException
* @author Liu lu
* @author Liu lu
* date 2023-02-09
* date 2023-02-09
*/
*/
public
function
uploadLocalFile
(
string
$localFilePath
,
string
$ossFilePath
)
public
function
uploadLocalFile
(
string
$localFilePath
,
string
$ossFilePath
,
$fixedDir
=
false
)
{
{
$extension
=
pathinfo
(
parse_url
(
$localFilePath
,
PHP_URL_PATH
),
PATHINFO_EXTENSION
);
$extension
=
pathinfo
(
parse_url
(
$localFilePath
,
PHP_URL_PATH
),
PATHINFO_EXTENSION
);
// $ossFilePath = 'oss2/'.env('APP_ENV').'/'.env('APP_NAME') ."/{$ossFilePath}/". md5($localFilePath).'.'.$extension;
if
(
$fixedDir
){
$ossFilePath
=
'oss2/'
.
env
(
'APP_ENV'
)
.
'/'
.
env
(
'APP_NAME'
)
.
"/
{
$ossFilePath
}
/"
.
md5
(
$localFilePath
)
.
'.'
.
$extension
;
$fileName
=
$this
->
genUniqueFileName
()
.
'.'
.
$extension
;
}
else
{
$ossFilePath
=
'oss2/'
.
$this
->
appDev
.
'/'
.
$this
->
appName
.
"/
{
$ossFilePath
}
/"
.
today
()
.
'/'
.
$fileName
;
$fileName
=
$this
->
genUniqueFileName
()
.
'.'
.
$extension
;
$ossFilePath
=
'oss2/'
.
$this
->
appDev
.
'/'
.
$this
->
appName
.
"/
{
$ossFilePath
}
/"
.
today
()
.
'/'
.
$fileName
;
}
try
{
try
{
$oss
=
$this
->
factory
->
get
(
'oss'
);
$oss
=
$this
->
factory
->
get
(
'oss'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment