33namespace App \Http \Controllers \Bus ;
44
55use App \Http \Repository \AccessToken ;
6+ use AuroraLZDF \Bigfile \Traits \TraitBigfileChunk ;
67use Curl \Http ;
78use Illuminate \Http \Request ;
89use App \Http \Controllers \Controller ;
1112
1213class AutoController extends Controller
1314{
15+ use TraitBigfileChunk;
16+
1417 /**
1518 * @var Http 请求类
1619 */
@@ -20,6 +23,45 @@ public function __construct()
2023 {
2124 $ this ->http || $ this ->http = Http::getInstent ();
2225 }
26+
27+ /**
28+ * 展示视图
29+ *
30+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|\think\response\View
31+ */
32+ public function loadView ()
33+ {
34+ $ data = [
35+ 'chunk_size ' => config ('bigfile.chunk_size ' ),
36+ 'max_size ' => config ('bigfile.max_size ' ),
37+ 'user_id ' => Auth ()->id (),
38+ ];
39+ return view ('bigfile.bigfile ' , compact ('data ' ));
40+ }
41+
42+ /**
43+ * 上传操作
44+ *
45+ * @param Request $request
46+ * @return \Illuminate\Http\JsonResponse
47+ *
48+ * @throws \Exception
49+ */
50+ public function upload (Request $ request )
51+ {
52+ $ data = $ request ->all ();
53+ $ action = $ request ->input ('act ' );
54+
55+ if (isset ($ action ) && $ action == 'upload ' ) {
56+
57+ $ result = $ this ->uploadToServer ($ data );
58+ return response ()->json ($ result );
59+ }
60+
61+ $ result = $ this ->uploadChunk ($ request );
62+ return response ()->json ($ result );
63+ }
64+
2365 /**
2466 * 获取七牛 Token 的方法
2567 *
0 commit comments