<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Traits; use ModStart\Core\Input\Response; use ModStart\Data\Event\DataFileUploadedEvent; trait LocalMultipartUploadTrait { public function multiPartInit($pmJAc) { goto Xbh8P; i36Fk: $this->uploadChunkTokenAndUpdateToken($I82X8); goto H3qye; Xbh8P: $I82X8 = $this->multiPartInitToken($pmJAc); goto i36Fk; H3qye: return Response::generate(0, 'ok', $I82X8); goto RvGIi; RvGIi: } public function multiPartUpload($pmJAc) { goto pJdRt; ECmXZ: if (!isset($do_OL['chunk'])) { $do_OL['chunk'] = 0; } goto kav6I; G6Hno: $IaeCl['chunk'] = $do_OL['chunk']; goto lPGNl; kav6I: if (empty($do_OL['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto vwpSL; vwpSL: $IaeCl['chunks'] = $do_OL['chunks']; goto G6Hno; kP8zb: $IaATa = $pmJAc['category']; goto ZV7VC; pJdRt: $I82X8 = $this->multiPartInitToken($pmJAc); goto OkjwR; AFOub: if ($IaeCl['chunk'] < $IaeCl['chunks']) { goto ET5aq; p9mYv: $IaeCl['finished'] = false; goto Kn4sz; rbDbU: $I82X8['chunkUploaded'] = $IaeCl['chunk'] + 1; goto XlcAP; RcAxE: $this->localStorage->put($w7Kaa . '.' . $IaeCl['chunk'], $ohNZt); goto rbDbU; XlcAP: $this->uploadChunkTokenAndUpdateToken($I82X8); goto p9mYv; ET5aq: $ohNZt = file_get_contents($IaeCl['file']->getRealPath()); goto RcAxE; Kn4sz: if ($I82X8['chunkUploaded'] == $IaeCl['chunks']) { goto P6o6q; juSsm: DataFileUploadedEvent::fire($this->remoteType, $IaATa, $I82X8['fullPath']); goto b0W9J; b0W9J: $t5kxe = $this->repository->addTemp($IaATa, $I82X8['path'], $I82X8['name'], $I82X8['size'], empty($I82X8['md5']) ? null : $I82X8['md5']); goto xk9qM; c9jzu: $this->uploadChunkTokenAndDeleteToken($I82X8); goto OOd_l; NRH7j: $IaeCl['finished'] = true; goto GlSM1; nVSSI: if ($KOPVY != $I82X8['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $KOPVY . ',' . $I82X8['size'] . ') ShouldRetryUpload'); } goto DbzzK; rp1Tu: @unlink(public_path($w7Kaa)); goto juSsm; AdEWH: $IaeCl['preview'] = $this->getDriverFullPath($I82X8['fullPath']); goto NRH7j; OOd_l: $KOPVY = $this->localStorage->size($w7Kaa); goto nVSSI; P6o6q: $this->combine($w7Kaa); goto c9jzu; xk9qM: $IaeCl['data'] = $t5kxe; goto aWfmE; aWfmE: $IaeCl['path'] = $I82X8['fullPath']; goto AdEWH; DbzzK: $this->saveLocalToRemote($w7Kaa, $I82X8['fullPath']); goto rp1Tu; GlSM1: } goto Aqej2; Aqej2: } goto ade1F; vraD3: if (!isset($do_OL['chunks'])) { $do_OL['chunks'] = 1; } goto ECmXZ; bTL8E: $w7Kaa = self::DATA_CHUNK . '/data/' . $I82X8['hash']; goto AFOub; lPGNl: $IaeCl['file'] = $do_OL['file']; goto bTL8E; ade1F: return Response::generate(0, 'ok', $IaeCl); goto lKcm2; OkjwR: $do_OL = $pmJAc['input']; goto kP8zb; ZV7VC: $IaeCl = array(); goto vraD3; lKcm2: } private function combine($fWBvH) { goto xQA85; mZM_H: fclose($cD3KZ); goto spzg6; jzL1Z: if (flock($cD3KZ, LOCK_EX)) { for ($JhHfm = 0;; $JhHfm++) { if (!$this->localStorage->has($fWBvH . '.' . $JhHfm)) { break; } $ohNZt = file_get_contents($eMsN6 . $fWBvH . '.' . $JhHfm); fwrite($cD3KZ, $ohNZt); @unlink($eMsN6 . $fWBvH . '.' . $JhHfm); } flock($cD3KZ, LOCK_UN); } goto mZM_H; kp90o: $cD3KZ = @fopen($eMsN6 . $fWBvH, 'wb'); goto jzL1Z; xQA85: $eMsN6 = config('filesystems.disks.data.root'); goto kp90o; spzg6: } }