<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Traits; use ModStart\Core\Input\Response; use ModStart\Data\Event\DataFileUploadedEvent; trait LocalMultipartUploadTrait { public function multiPartInit($mattM) { goto lcFVU; BSU_z: $this->uploadChunkTokenAndUpdateToken($faQ3n); goto Psav5; Psav5: return Response::generate(0, 'ok', $faQ3n); goto Ob4oj; lcFVU: $faQ3n = $this->multiPartInitToken($mattM); goto BSU_z; Ob4oj: } public function multiPartUpload($mattM) { goto Ked7K; QY3Zy: $vfMTB = $mattM['input']; goto aVX12; pBehI: if ($dTnlu['chunk'] < $dTnlu['chunks']) { goto KKXFg; Uc5cc: if ($faQ3n['chunkUploaded'] == $dTnlu['chunks']) { goto uWabC; hi29z: $dTnlu['path'] = $faQ3n['fullPath']; goto ZLWIy; SuCdS: $this->uploadChunkTokenAndDeleteToken($faQ3n); goto c4v1v; uWabC: $this->combine($g5mOK); goto SuCdS; h_RiO: $this->saveLocalToRemote($g5mOK, $faQ3n['fullPath']); goto bKRW8; dY4NR: if ($LxBwP != $faQ3n['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $LxBwP . ',' . $faQ3n['size'] . ') ShouldRetryUpload'); } goto h_RiO; ZLWIy: $dTnlu['preview'] = $this->getDriverFullPath($faQ3n['fullPath']); goto t9daK; t9daK: $dTnlu['finished'] = true; goto Kiyv9; bKRW8: @unlink(public_path($g5mOK)); goto WNpnS; IAlRp: $dTnlu['data'] = $EnSJE; goto hi29z; WNpnS: DataFileUploadedEvent::fire($this->remoteType, $PW0Jg, $faQ3n['fullPath']); goto jWe07; c4v1v: $LxBwP = $this->localStorage->size($g5mOK); goto dY4NR; jWe07: $EnSJE = $this->repository->addTemp($PW0Jg, $faQ3n['path'], $faQ3n['name'], $faQ3n['size'], empty($faQ3n['md5']) ? null : $faQ3n['md5']); goto IAlRp; Kiyv9: } goto x_8T0; KKXFg: $gP2DQ = file_get_contents($dTnlu['file']->getRealPath()); goto Vza8L; Vza8L: $this->localStorage->put($g5mOK . '.' . $dTnlu['chunk'], $gP2DQ); goto GlTY5; GlTY5: $faQ3n['chunkUploaded'] = $dTnlu['chunk'] + 1; goto ZEZFR; ZS_mP: $dTnlu['finished'] = false; goto Uc5cc; ZEZFR: $this->uploadChunkTokenAndUpdateToken($faQ3n); goto ZS_mP; x_8T0: } goto z7WFh; Ked7K: $faQ3n = $this->multiPartInitToken($mattM); goto QY3Zy; rGJ4l: if (!isset($vfMTB['chunk'])) { $vfMTB['chunk'] = 0; } goto r1vso; DpX9X: $dTnlu = array(); goto YeM1d; aVX12: $PW0Jg = $mattM['category']; goto DpX9X; r1vso: if (empty($vfMTB['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto G33HL; Op2x5: $g5mOK = self::DATA_CHUNK . '/data/' . $faQ3n['hash']; goto pBehI; UQ5xZ: $dTnlu['chunk'] = $vfMTB['chunk']; goto cVVht; YeM1d: if (!isset($vfMTB['chunks'])) { $vfMTB['chunks'] = 1; } goto rGJ4l; z7WFh: return Response::generate(0, 'ok', $dTnlu); goto X8cw9; G33HL: $dTnlu['chunks'] = $vfMTB['chunks']; goto UQ5xZ; cVVht: $dTnlu['file'] = $vfMTB['file']; goto Op2x5; X8cw9: } private function combine($WF06r) { goto Vld3Q; vX699: $jF2wW = @fopen($Bhs5s . $WF06r, 'wb'); goto uqPzb; Vld3Q: $Bhs5s = config('filesystems.disks.data.root'); goto vX699; ZrEK0: fclose($jF2wW); goto VYNNt; uqPzb: if (flock($jF2wW, LOCK_EX)) { for ($jqibn = 0;; $jqibn++) { if (!$this->localStorage->has($WF06r . '.' . $jqibn)) { break; } $gP2DQ = file_get_contents($Bhs5s . $WF06r . '.' . $jqibn); fwrite($jF2wW, $gP2DQ); @unlink($Bhs5s . $WF06r . '.' . $jqibn); } flock($jF2wW, LOCK_UN); } goto ZrEK0; VYNNt: } }