mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-08-07 06:19:44 +08:00
ComposerUpdate&优化文件上传
This commit is contained in:
parent
4b1ee3933a
commit
059e6459a8
@ -57,9 +57,8 @@ class Upload extends Controller
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
$this->name = input('name', null);
|
||||
$this->safe = boolval(input('safe'));
|
||||
$data = ['uptype' => $this->getType(), 'xkey' => input('xkey')];
|
||||
list($this->name, $this->safe) = [input('name', null), boolval(input('safe'))];
|
||||
$data = ['uptype' => $this->getType(), 'xkey' => input('xkey'), 'safe' => $this->safe];
|
||||
if ($info = Storage::instance($data['uptype'])->info($data['xkey'], $this->safe, $this->name)) {
|
||||
$data['url'] = $info['url'];
|
||||
$this->success('文件已经上传', $data, 200);
|
||||
@ -78,8 +77,7 @@ class Upload extends Controller
|
||||
$data['OSSAccessKeyId'] = $token['keyid'];
|
||||
$data['server'] = AliossStorage::instance()->upload();
|
||||
}
|
||||
$data['safe'] = intval($this->safe);
|
||||
$this->success('获取上传参数', $data, 404);
|
||||
$this->success('获取授权参数', $data, 404);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,7 +104,16 @@ class Upload extends Controller
|
||||
}
|
||||
list($this->safe, $this->uptype, $this->name) = [boolval(input('safe')), $this->getType(), input('xkey')];
|
||||
if (empty($this->name)) $this->name = Storage::name($file->getPathname(), $this->extension, '', 'md5_file');
|
||||
$info = Storage::instance($this->uptype)->set($this->name, file_get_contents($file->getRealPath()), $this->safe, $file->getOriginalName());
|
||||
if ($this->uptype === 'local') {
|
||||
$local = LocalStorage::instance();
|
||||
$realpath = dirname($realname = $local->path($this->name, $this->safe));
|
||||
file_exists($realpath) && is_dir($realpath) || mkdir($realpath, 0755, true);
|
||||
@move_uploaded_file($file->getPathname(), $realname);
|
||||
$info = $local->info($this->name, $this->safe, $file->getOriginalName());
|
||||
} else {
|
||||
$bina = file_get_contents($file->getRealPath());
|
||||
$info = Storage::instance($this->uptype)->set($this->name, $bina, $this->safe, $file->getOriginalName());
|
||||
}
|
||||
if (is_array($info) && isset($info['url'])) {
|
||||
return json(['uploaded' => true, 'filename' => $this->name, 'url' => $this->safe ? $this->name : $info['url']]);
|
||||
} else {
|
||||
|
8
composer.lock
generated
8
composer.lock
generated
@ -909,12 +909,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e"
|
||||
"reference": "233e269155871ca9ef6b818536687d5862acef5b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e",
|
||||
"reference": "ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/233e269155871ca9ef6b818536687d5862acef5b",
|
||||
"reference": "233e269155871ca9ef6b818536687d5862acef5b",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -958,7 +958,7 @@
|
||||
],
|
||||
"description": "ThinkPHP v6.0 Development Library",
|
||||
"homepage": "http://framework.thinkadmin.top",
|
||||
"time": "2020-03-25T02:06:11+00:00"
|
||||
"time": "2020-03-26T10:28:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "zoujingli/wechat-developer",
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -935,12 +935,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e"
|
||||
"reference": "233e269155871ca9ef6b818536687d5862acef5b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e",
|
||||
"reference": "ec34c3a4e22f6f9a484c4728db0c63e6c9e0371e",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/233e269155871ca9ef6b818536687d5862acef5b",
|
||||
"reference": "233e269155871ca9ef6b818536687d5862acef5b",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -956,7 +956,7 @@
|
||||
"ext-json": "*",
|
||||
"topthink/framework": "^6.0"
|
||||
},
|
||||
"time": "2020-03-25T02:06:11+00:00",
|
||||
"time": "2020-03-26T10:28:21+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"think": {
|
||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// This file is automatically generated at:2020-03-25 10:13:48
|
||||
// This file is automatically generated at:2020-03-27 10:03:07
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\app\\Service',
|
||||
|
@ -138,7 +138,7 @@ class WorkQueue extends Queue
|
||||
if (isset($this->queue['loops_time']) && $this->queue['loops_time'] > 0) {
|
||||
try {
|
||||
$this->qService->initialize($this->code)->reset($this->queue['loops_time']);
|
||||
} catch (\Exception $exception) {
|
||||
} catch (\Exception|\Error $exception) {
|
||||
$this->app->log->error("Queue {$this->queue['code']} Loops Failed. {$exception->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
@ -139,8 +139,9 @@ class QueueService extends Service
|
||||
if (empty($rscript) && ($queue = $this->app->db->name('SystemQueue')->where($map)->find())) {
|
||||
throw new \think\admin\Exception(lang('think_library_queue_exist'), 0, $queue['code']);
|
||||
}
|
||||
$this->code = CodeExtend::uniqidDate(16, 'Q');
|
||||
$this->app->db->name('SystemQueue')->strict(false)->failException(true)->insert([
|
||||
'code' => $this->code = CodeExtend::uniqidDate(16, 'Q'),
|
||||
'code' => $this->code,
|
||||
'title' => $title,
|
||||
'command' => $command,
|
||||
'attempts' => '0',
|
||||
|
Loading…
x
Reference in New Issue
Block a user