<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Traits; use ModStart\Core\Input\Response; use ModStart\Data\Event\DataFileUploadedEvent; trait LocalMultipartUploadTrait { public function multiPartInit($zlK8N) { goto v4IAn; iJgI2: $this->uploadChunkTokenAndUpdateToken($iWMtt); goto ALwLh; ALwLh: return Response::generate(0, 'ok', $iWMtt); goto sx9q3; v4IAn: $iWMtt = $this->multiPartInitToken($zlK8N); goto iJgI2; sx9q3: } public function multiPartUpload($zlK8N) { goto ij17i; fPsbT: if (empty($Zxpx_['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto w1gT0; sKA25: if (!isset($Zxpx_['chunk'])) { $Zxpx_['chunk'] = 0; } goto fPsbT; ORB4j: $jc3Nv = self::DATA_CHUNK . '/data/' . $iWMtt['hash']; goto sV2JQ; w1gT0: $OTBPk['chunks'] = $Zxpx_['chunks']; goto RaWmb; sV2JQ: if ($OTBPk['chunk'] < $OTBPk['chunks']) { goto x3IKu; ATXJJ: if ($iWMtt['chunkUploaded'] == $OTBPk['chunks']) { goto ceNl4; ceNl4: $this->combine($jc3Nv); goto kS45O; TFoBe: $this->saveLocalToRemote($jc3Nv, $iWMtt['fullPath']); goto m3514; oU4cE: $OTBPk['path'] = $iWMtt['fullPath']; goto WV7bJ; jCxSV: $OmMHF = $this->localStorage->size($jc3Nv); goto yE0bg; WV7bJ: $OTBPk['preview'] = $this->getDriverFullPath($iWMtt['fullPath']); goto bohxN; LmxgI: $OTBPk['data'] = $c39Kb; goto oU4cE; yE0bg: if ($OmMHF != $iWMtt['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $OmMHF . ',' . $iWMtt['size'] . ') ShouldRetryUpload'); } goto TFoBe; kS45O: $this->uploadChunkTokenAndDeleteToken($iWMtt); goto jCxSV; ILGnZ: DataFileUploadedEvent::fire($this->remoteType, $QLOpy, $iWMtt['fullPath']); goto e4J4R; m3514: @unlink(public_path($jc3Nv)); goto ILGnZ; bohxN: $OTBPk['finished'] = true; goto LLZUx; e4J4R: $c39Kb = $this->repository->addTemp($QLOpy, $iWMtt['path'], $iWMtt['name'], $iWMtt['size'], empty($iWMtt['md5']) ? null : $iWMtt['md5']); goto LmxgI; LLZUx: } goto ux9sy; JJZcC: $this->uploadChunkTokenAndUpdateToken($iWMtt); goto oqU4n; DkVhX: $this->localStorage->put($jc3Nv . '.' . $OTBPk['chunk'], $DTnPC); goto LBh_p; LBh_p: $iWMtt['chunkUploaded'] = $OTBPk['chunk'] + 1; goto JJZcC; oqU4n: $OTBPk['finished'] = false; goto ATXJJ; x3IKu: $DTnPC = file_get_contents($OTBPk['file']->getRealPath()); goto DkVhX; ux9sy: } goto Z8pxf; spr2J: $Zxpx_ = $zlK8N['input']; goto Efxlw; RaWmb: $OTBPk['chunk'] = $Zxpx_['chunk']; goto a9uxr; ayshM: if (!isset($Zxpx_['chunks'])) { $Zxpx_['chunks'] = 1; } goto sKA25; Efxlw: $QLOpy = $zlK8N['category']; goto FKWgA; ij17i: $iWMtt = $this->multiPartInitToken($zlK8N); goto spr2J; Z8pxf: return Response::generate(0, 'ok', $OTBPk); goto yaM1c; FKWgA: $OTBPk = array(); goto ayshM; a9uxr: $OTBPk['file'] = $Zxpx_['file']; goto ORB4j; yaM1c: } private function combine($RLMU5) { goto cgYIP; cgYIP: $SksVn = config('filesystems.disks.data.root'); goto IuqTZ; IuqTZ: $Y05AU = @fopen($SksVn . $RLMU5, 'wb'); goto yZAE1; laNFB: fclose($Y05AU); goto K1_X4; yZAE1: if (flock($Y05AU, LOCK_EX)) { for ($VJ5vg = 0;; $VJ5vg++) { if (!$this->localStorage->has($RLMU5 . '.' . $VJ5vg)) { break; } $DTnPC = file_get_contents($SksVn . $RLMU5 . '.' . $VJ5vg); fwrite($Y05AU, $DTnPC); @unlink($SksVn . $RLMU5 . '.' . $VJ5vg); } flock($Y05AU, LOCK_UN); } goto laNFB; K1_X4: } }