<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Storage; use ModStart\Core\Input\Response; use ModStart\Data\AbstractDataStorage; use ModStart\Data\Event\DataFileUploadedEvent; class FileDataStorage extends AbstractDataStorage { public function init() { } public function get($RLMU5) { if ($this->localStorage->has($RLMU5)) { return $this->localStorage->get($RLMU5); } return null; } public function size($RLMU5) { return $this->localStorage->size($RLMU5); } public function put($RLMU5, $DTnPC) { $this->localStorage->put($RLMU5, $DTnPC); } public function has($RLMU5) { return $this->localStorage->has($RLMU5); } public function delete($RLMU5) { $this->localStorage->delete($RLMU5); } public function move($SoJ1U, $blQsO) { $this->localStorage->copy($SoJ1U, $blQsO); $this->localStorage->delete($SoJ1U); } public function multiPartInit($zlK8N) { goto IqcmU; oihLd: $this->uploadChunkTokenAndUpdateToken($iWMtt); goto bHGGW; IqcmU: $iWMtt = $this->multiPartInitToken($zlK8N); goto oihLd; bHGGW: return Response::generate(0, 'ok', $iWMtt); goto YCKEC; YCKEC: } public function multiPartUpload($zlK8N) { goto rZCSO; LIQb9: $OTBPk = array(); goto jZOcW; TQFPf: $Zxpx_ = $zlK8N['input']; goto KhhyH; rZCSO: $iWMtt = $this->multiPartInitToken($zlK8N); goto TQFPf; rRtyp: if ($OTBPk['chunk'] < $OTBPk['chunks']) { goto FlFPl; qtHBl: if ($iWMtt['chunkUploaded'] == $OTBPk['chunks']) { goto klBpt; gc7gC: $OTBPk['finished'] = true; goto pWxyR; nLfdJ: $OTBPk['preview'] = $this->getDriverFullPath($iWMtt['fullPath']); goto gc7gC; L_H_o: $this->move($jc3Nv, $iWMtt['fullPath']); goto DeLOK; DeLOK: DataFileUploadedEvent::fire(null, $QLOpy, $iWMtt['fullPath']); goto uMrzH; klBpt: $this->combine($jc3Nv); goto EZ168; EZ168: $this->uploadChunkTokenAndDeleteToken($iWMtt); goto ywTgS; PoCb0: $OTBPk['path'] = $iWMtt['fullPath']; goto nLfdJ; SseDq: if ($OmMHF != $iWMtt['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $OmMHF . ',' . $iWMtt['size'] . ') ShouldRetryUpload'); } goto L_H_o; FxpCY: $OTBPk['data'] = $c39Kb; goto PoCb0; ywTgS: $OmMHF = $this->size($jc3Nv); goto SseDq; uMrzH: $c39Kb = $this->repository->addTemp($QLOpy, $iWMtt['path'], $iWMtt['name'], $iWMtt['size'], empty($iWMtt['md5']) ? null : $iWMtt['md5']); goto FxpCY; pWxyR: } goto bfZL1; FlFPl: $ju0cF = $OTBPk['file']->getRealPath(); goto X0MfF; d2YZz: $iWMtt['chunkUploaded'] = $OTBPk['chunk'] + 1; goto iIh5R; sargY: $this->localStorage->put($jc3Nv . '.' . $OTBPk['chunk'], $DTnPC); goto d2YZz; IH2Uw: $OTBPk['finished'] = false; goto qtHBl; iIh5R: $this->uploadChunkTokenAndUpdateToken($iWMtt); goto IH2Uw; uszjC: $DTnPC = file_get_contents($ju0cF); goto sargY; X0MfF: if (false === $ju0cF) { $ju0cF = $OTBPk['file']->getPathname(); } goto uszjC; bfZL1: } goto ifsX1; gKaZD: if (!isset($Zxpx_['chunk'])) { $Zxpx_['chunk'] = 0; } goto CzgVC; jZOcW: if (!isset($Zxpx_['chunks'])) { $Zxpx_['chunks'] = 1; } goto gKaZD; KhhyH: $QLOpy = $zlK8N['category']; goto LIQb9; Cyd85: $OTBPk['chunk'] = $Zxpx_['chunk']; goto mHXDI; klUud: $OTBPk['chunks'] = $Zxpx_['chunks']; goto Cyd85; CzgVC: if (empty($Zxpx_['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto klUud; mHXDI: $OTBPk['file'] = $Zxpx_['file']; goto rZ2bL; rZ2bL: $jc3Nv = self::DATA_CHUNK . '/data/' . $iWMtt['hash']; goto rRtyp; ifsX1: return Response::generate(0, 'ok', $OTBPk); goto PoqOO; PoqOO: } private function combine($RLMU5) { goto T1Rmq; kI2Df: fclose($Y05AU); goto Ajbr4; E3_or: 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 kI2Df; GypGg: $Y05AU = @fopen($SksVn . $RLMU5, 'wb'); goto E3_or; T1Rmq: $SksVn = config('filesystems.disks.data.root'); goto GypGg; Ajbr4: } }