<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Traits; use ModStart\Core\Input\Response; use ModStart\Data\Event\DataFileUploadedEvent; trait LocalMultipartUploadTrait { public function multiPartInit($pFM9U) { goto y8Azp; xpcc2: $this->uploadChunkTokenAndUpdateToken($K6b7B); goto wg3zr; wg3zr: return Response::generate(0, 'ok', $K6b7B); goto sCm5H; y8Azp: $K6b7B = $this->multiPartInitToken($pFM9U); goto xpcc2; sCm5H: } public function multiPartUpload($pFM9U) { goto l3xaR; jdy8p: $Sj05q = array(); goto IZFdC; gh8j_: return Response::generate(0, 'ok', $Sj05q); goto xxihb; wCx4T: $TG2we = $pFM9U['input']; goto Kpj3P; l3xaR: $K6b7B = $this->multiPartInitToken($pFM9U); goto wCx4T; iXydb: if ($Sj05q['chunk'] < $Sj05q['chunks']) { goto UJu2v; asrXG: $this->uploadChunkTokenAndUpdateToken($K6b7B); goto rgtoK; UJu2v: $LTC5O = file_get_contents($Sj05q['file']->getRealPath()); goto EUXrJ; e4Wlf: if ($K6b7B['chunkUploaded'] == $Sj05q['chunks']) { goto Che7W; WKBZk: if ($QaVLR != $K6b7B['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $QaVLR . ',' . $K6b7B['size'] . ') ShouldRetryUpload'); } goto pF3cu; m12ev: $this->uploadChunkTokenAndDeleteToken($K6b7B); goto o6qcH; bXPpi: $Sj05q['data'] = $tk0m6; goto hG7nR; bIUo5: $Sj05q['finished'] = true; goto x6QWq; hG7nR: $Sj05q['path'] = $K6b7B['fullPath']; goto ee7zU; DKLcS: DataFileUploadedEvent::fire($this->remoteType, $FVUIh, $K6b7B['fullPath']); goto cP9Ta; nTIns: @unlink(public_path($rcRe8)); goto DKLcS; cP9Ta: $tk0m6 = $this->repository->addTemp($FVUIh, $K6b7B['path'], $K6b7B['name'], $K6b7B['size'], empty($K6b7B['md5']) ? null : $K6b7B['md5']); goto bXPpi; ee7zU: $Sj05q['preview'] = $this->getDriverFullPath($K6b7B['fullPath']); goto bIUo5; o6qcH: $QaVLR = $this->localStorage->size($rcRe8); goto WKBZk; pF3cu: $this->saveLocalToRemote($rcRe8, $K6b7B['fullPath']); goto nTIns; Che7W: $this->combine($rcRe8); goto m12ev; x6QWq: } goto OQ3sS; rZU28: $K6b7B['chunkUploaded'] = $Sj05q['chunk'] + 1; goto asrXG; rgtoK: $Sj05q['finished'] = false; goto e4Wlf; EUXrJ: $this->localStorage->put($rcRe8 . '.' . $Sj05q['chunk'], $LTC5O); goto rZU28; OQ3sS: } goto gh8j_; ujKKV: if (empty($TG2we['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto WEuZV; hiWTV: $Sj05q['file'] = $TG2we['file']; goto YAJVF; IZFdC: if (!isset($TG2we['chunks'])) { $TG2we['chunks'] = 1; } goto jAUbs; jAUbs: if (!isset($TG2we['chunk'])) { $TG2we['chunk'] = 0; } goto ujKKV; YAJVF: $rcRe8 = self::DATA_CHUNK . '/data/' . $K6b7B['hash']; goto iXydb; WEuZV: $Sj05q['chunks'] = $TG2we['chunks']; goto JCFO0; Kpj3P: $FVUIh = $pFM9U['category']; goto jdy8p; JCFO0: $Sj05q['chunk'] = $TG2we['chunk']; goto hiWTV; xxihb: } private function combine($sCmIC) { goto mNMn_; hEhOG: $OKHV6 = @fopen($RFcbL . $sCmIC, 'wb'); goto KGP3Y; KGP3Y: if (flock($OKHV6, LOCK_EX)) { for ($Xn_Rr = 0;; $Xn_Rr++) { if (!$this->localStorage->has($sCmIC . '.' . $Xn_Rr)) { break; } $LTC5O = file_get_contents($RFcbL . $sCmIC . '.' . $Xn_Rr); fwrite($OKHV6, $LTC5O); @unlink($RFcbL . $sCmIC . '.' . $Xn_Rr); } flock($OKHV6, LOCK_UN); } goto AvKXn; mNMn_: $RFcbL = config('filesystems.disks.data.root'); goto hEhOG; AvKXn: fclose($OKHV6); goto rSDwF; rSDwF: } }