Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-rpc
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-rpc
Commits
770ece9a
Commit
770ece9a
authored
Aug 25, 2020
by
周智鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新micro-api-flow专用上传rpc 其余模块的申请rpc
parent
5bea017d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
0 deletions
+61
-0
UploadManager.php
src/Manager/UploadManager.php
+44
-0
ProcessFormServiceInterface.php
src/Service/Interfaces/Flow/ProcessFormServiceInterface.php
+17
-0
No files found.
src/Manager/UploadManager.php
View file @
770ece9a
...
...
@@ -118,6 +118,50 @@ class UploadManager
}
}
/**
* 文件上传方法(micro-api-flow)
* @param UploadedFile $file 上传的文件
* @param array $options 配置参数
* @param bool $realPath
* @return string
* @throws HttpResponseException
*/
public
static
function
uploadFileGetName
(
$file
,
$options
=
[],
$realPath
=
false
)
{
$documentRoot
=
config
(
'server.settings.document_root'
);
if
(
!
$documentRoot
)
{
throw
new
\RuntimeException
(
'未配置静态资源'
);
}
$options
=
self
::
parseOptions
(
$options
);
if
(
$file
->
isValid
())
{
$extension
=
strtolower
(
$file
->
getExtension
());
// 通过扩展名判断类型
if
(
!
in_array
(
$extension
,
$options
[
'mime'
]))
{
throw
new
HttpResponseException
(
'文件类型不支持,目前只支持'
.
implode
(
','
,
$options
[
'mime'
]));
}
// 判断文件大小
if
(
$file
->
getSize
()
>
$options
[
'maxSize'
])
{
throw
new
HttpResponseException
(
'文件超出系统规定的大小,最大不能超过'
.
num_2_file_size
(
$options
[
'maxSize'
]));
}
// 文件重命名,由当前日期时间 + 唯一ID + 扩展名
$fileName
=
date
(
'YmdHis'
)
.
uniqid
()
.
'.'
.
$extension
;
$name
=
$file
->
toArray
()[
'name'
];
$savePath
=
self
::
parsePath
(
$options
,
$documentRoot
)
.
$fileName
.
'_'
.
$name
;
$file
->
moveTo
(
$savePath
);
if
(
$file
->
isMoved
())
{
if
(
$realPath
)
{
return
$savePath
;
}
else
{
return
str_replace
(
$documentRoot
,
''
,
$savePath
);
}
}
else
{
throw
new
HttpResponseException
(
'文件保存失败'
);
}
}
else
{
throw
new
HttpResponseException
(
'文件无效'
);
}
}
/**
* 生成头像
* @return string|string[]
...
...
src/Service/Interfaces/Flow/ProcessFormServiceInterface.php
0 → 100644
View file @
770ece9a
<?php
namespace
Meibuyu\Micro\Service\Interfaces\Flow
;
interface
ProcessFormServiceInterface
{
/**
* 创建流程申请
* @param $processId 流程id
* @param $url 表单图片地址
* @param $data 表单详细内容
* @return mixed
*/
public
function
createProcessForm
(
$processId
,
$url
,
$data
);
}
\ No newline at end of file
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