优化文件上传
This commit is contained in:
parent
3722bf3bbc
commit
5fd67432b1
@ -101,7 +101,7 @@ class File extends BasicApi
|
|||||||
$this->error($e->getMessage(), 500);
|
$this->error($e->getMessage(), 500);
|
||||||
}
|
}
|
||||||
$info = $uploadInfo['uploadInfo'];
|
$info = $uploadInfo['uploadInfo'];
|
||||||
|
unset($uploadInfo);
|
||||||
$fileData = [
|
$fileData = [
|
||||||
'extension' => $info->getExtension(),
|
'extension' => $info->getExtension(),
|
||||||
'file_type' => $info->getInfo()['type'],
|
'file_type' => $info->getInfo()['type'],
|
||||||
@ -134,11 +134,10 @@ class File extends BasicApi
|
|||||||
!isset($data['taskCode']) && $data['taskCode'] = '';
|
!isset($data['taskCode']) && $data['taskCode'] = '';
|
||||||
$fileResult = \app\common\Model\File::createFile($data['projectCode'], $fileData);
|
$fileResult = \app\common\Model\File::createFile($data['projectCode'], $fileData);
|
||||||
|
|
||||||
unset($fileData);
|
|
||||||
unset($info);
|
unset($info);
|
||||||
//文件碎片移除
|
//文件碎片移除
|
||||||
foreach ($fileList as $file) {
|
foreach ($fileList as $file) {
|
||||||
@unlink($file);
|
unlink($file);
|
||||||
}
|
}
|
||||||
$fileInfo = \app\common\Model\File::where(['code' => $fileResult['code']])->find();
|
$fileInfo = \app\common\Model\File::where(['code' => $fileResult['code']])->find();
|
||||||
if ($data['taskCode']) {
|
if ($data['taskCode']) {
|
||||||
|
@ -328,7 +328,7 @@ class FileService
|
|||||||
* @throws \think\Exception
|
* @throws \think\Exception
|
||||||
* @throws \think\exception\PDOException
|
* @throws \think\exception\PDOException
|
||||||
*/
|
*/
|
||||||
public static function qiniu($filename, $content)
|
public static function qiniu($filename, $content, $append = false)
|
||||||
{
|
{
|
||||||
$auth = new Auth(sysconf('storage_qiniu_access_key'), sysconf('storage_qiniu_secret_key'));
|
$auth = new Auth(sysconf('storage_qiniu_access_key'), sysconf('storage_qiniu_secret_key'));
|
||||||
$token = $auth->uploadToken(sysconf('storage_qiniu_bucket'));
|
$token = $auth->uploadToken(sysconf('storage_qiniu_bucket'));
|
||||||
@ -351,7 +351,7 @@ class FileService
|
|||||||
* @throws \think\Exception
|
* @throws \think\Exception
|
||||||
* @throws \think\exception\PDOException
|
* @throws \think\exception\PDOException
|
||||||
*/
|
*/
|
||||||
public static function oss($filename, $content)
|
public static function oss($filename, $content, $append = false)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$endpoint = 'http://' . sysconf('storage_oss_domain');
|
$endpoint = 'http://' . sysconf('storage_oss_domain');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user