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
5f798f59
Commit
5f798f59
authored
Feb 09, 2023
by
chentianyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oss 路径加appName
parent
62a51b86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
UploadOssService.php
src/UploadOss/UploadOssService.php
+8
-2
No files found.
src/UploadOss/UploadOssService.php
View file @
5f798f59
...
@@ -33,6 +33,11 @@ class UploadOssService
...
@@ -33,6 +33,11 @@ class UploadOssService
*/
*/
private
$appDev
;
private
$appDev
;
/**
* @var string
*/
private
$appName
;
public
static
$options
=
[
public
static
$options
=
[
'maxSize'
=>
10
*
1024
*
1024
,
// 文件大小,10M
'maxSize'
=>
10
*
1024
*
1024
,
// 文件大小,10M
'mime'
=>
[
'jpeg'
,
'png'
,
'gif'
,
'jpg'
,
'svg'
,
'txt'
,
'pdf'
,
'xlsx'
,
'xls'
,
'doc'
,
'docx'
,
'rar'
,
'zip'
,
'csv'
],
// 允许上传的文件类型
'mime'
=>
[
'jpeg'
,
'png'
,
'gif'
,
'jpg'
,
'svg'
,
'txt'
,
'pdf'
,
'xlsx'
,
'xls'
,
'doc'
,
'docx'
,
'rar'
,
'zip'
,
'csv'
],
// 允许上传的文件类型
...
@@ -45,6 +50,7 @@ class UploadOssService
...
@@ -45,6 +50,7 @@ class UploadOssService
$ossConfig
=
$this
->
config
->
get
(
'file.storage.oss'
);
$ossConfig
=
$this
->
config
->
get
(
'file.storage.oss'
);
$this
->
urlPrefix
=
'https://'
.
$ossConfig
[
'bucket'
]
.
'.'
.
$ossConfig
[
'endpoint'
]
.
'/'
;
$this
->
urlPrefix
=
'https://'
.
$ossConfig
[
'bucket'
]
.
'.'
.
$ossConfig
[
'endpoint'
]
.
'/'
;
$this
->
appDev
=
$this
->
config
->
get
(
'app_env'
);
$this
->
appDev
=
$this
->
config
->
get
(
'app_env'
);
$this
->
appName
=
$this
->
config
->
get
(
'app_name'
);
}
}
/**
/**
...
@@ -61,7 +67,7 @@ class UploadOssService
...
@@ -61,7 +67,7 @@ class UploadOssService
$clientFilename
=
$image
->
getClientFilename
();
$clientFilename
=
$image
->
getClientFilename
();
$fileName
=
$uniqueFileName
?
(
$this
->
genUniqueFileName
()
.
'.'
.
$ext
)
:
$clientFilename
;
$fileName
=
$uniqueFileName
?
(
$this
->
genUniqueFileName
()
.
'.'
.
$ext
)
:
$clientFilename
;
$options
=
[
'mime'
=>
[
'jpeg'
,
'png'
,
'gif'
,
'jpg'
,
'svg'
]];
$options
=
[
'mime'
=>
[
'jpeg'
,
'png'
,
'gif'
,
'jpg'
,
'svg'
]];
$filePath
=
'oss2/'
.
$this
->
appDev
.
"/
$module
/images/"
.
today
()
.
"/
$userId
/"
.
$clientFilename
;
$filePath
=
'oss2/'
.
$this
->
appDev
.
"/
"
.
$this
->
appName
.
"/
$module
/images/"
.
today
()
.
"/
$userId
/"
.
$clientFilename
;
$this
->
upload
(
$image
,
$filePath
,
$options
);
$this
->
upload
(
$image
,
$filePath
,
$options
);
$model
=
new
FileModel
();
$model
=
new
FileModel
();
$model
=
$model
->
newInstance
([
$model
=
$model
->
newInstance
([
...
@@ -91,7 +97,7 @@ class UploadOssService
...
@@ -91,7 +97,7 @@ class UploadOssService
$ext
=
$file
->
getExtension
();
$ext
=
$file
->
getExtension
();
$clientFilename
=
$file
->
getClientFilename
();
$clientFilename
=
$file
->
getClientFilename
();
$fileName
=
$uniqueFileName
?
(
$this
->
genUniqueFileName
()
.
'.'
.
$ext
)
:
$clientFilename
;
$fileName
=
$uniqueFileName
?
(
$this
->
genUniqueFileName
()
.
'.'
.
$ext
)
:
$clientFilename
;
$filePath
=
'oss2/'
.
$this
->
appDev
.
"/
$module
/files/"
.
today
()
.
"/
$userId
/"
.
$clientFilename
;
$filePath
=
'oss2/'
.
$this
->
appDev
.
"/
"
.
$this
->
appName
.
"/
$module
/files/"
.
today
()
.
"/
$userId
/"
.
$clientFilename
;
$this
->
upload
(
$file
,
$filePath
,
$options
);
$this
->
upload
(
$file
,
$filePath
,
$options
);
$model
=
new
FileModel
();
$model
=
new
FileModel
();
$model
=
$model
->
newInstance
([
$model
=
$model
->
newInstance
([
...
...
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