<?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($aYJAK) { if ($this->localStorage->has($aYJAK)) { return $this->localStorage->get($aYJAK); } return null; } public function size($aYJAK) { return $this->localStorage->size($aYJAK); } public function put($aYJAK, $Afv_G) { $this->localStorage->put($aYJAK, $Afv_G); } public function has($aYJAK) { return $this->localStorage->has($aYJAK); } public function delete($aYJAK) { $this->localStorage->delete($aYJAK); } public function move($L_a53, $RP3dD) { $this->localStorage->copy($L_a53, $RP3dD); $this->localStorage->delete($L_a53); } public function multiPartInit($qHLCM) { goto mNZkL; Vv8gi: $this->uploadChunkTokenAndUpdateToken($EerLH); goto ydZpg; mNZkL: $EerLH = $this->multiPartInitToken($qHLCM); goto Vv8gi; ydZpg: return Response::generate(0, 'ok', $EerLH); goto XE4sY; XE4sY: } public function multiPartUpload($qHLCM) { goto DrrNR; BaOZi: $oJLhT = self::DATA_CHUNK . '/data/' . $EerLH['hash']; goto EWUkC; g3IVT: if (!isset($kFc4w['chunk'])) { $kFc4w['chunk'] = 0; } goto IocK3; IbTKi: $CnWtd['chunks'] = $kFc4w['chunks']; goto y0WHq; DrrNR: $EerLH = $this->multiPartInitToken($qHLCM); goto gtJyk; fLOnr: $ZRqAm = $qHLCM['category']; goto B1dHH; B1dHH: $CnWtd = array(); goto jEpIJ; jEpIJ: if (!isset($kFc4w['chunks'])) { $kFc4w['chunks'] = 1; } goto g3IVT; lUzHv: return Response::generate(0, 'ok', $CnWtd); goto KXIul; EWUkC: if ($CnWtd['chunk'] < $CnWtd['chunks']) { goto kE98f; Rr0Mf: $EerLH['chunkUploaded'] = $CnWtd['chunk'] + 1; goto Y5gZ6; jgfZs: if (false === $z8JHA) { $z8JHA = $CnWtd['file']->getPathname(); } goto vFfct; kE98f: $z8JHA = $CnWtd['file']->getRealPath(); goto jgfZs; RqbZD: $CnWtd['finished'] = false; goto QFaia; rCPAB: $this->localStorage->put($oJLhT . '.' . $CnWtd['chunk'], $Afv_G); goto Rr0Mf; Y5gZ6: $this->uploadChunkTokenAndUpdateToken($EerLH); goto RqbZD; vFfct: $Afv_G = file_get_contents($z8JHA); goto rCPAB; QFaia: if ($EerLH['chunkUploaded'] == $CnWtd['chunks']) { goto vBchi; RdwCt: if ($A33WR != $EerLH['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $A33WR . ',' . $EerLH['size'] . ') ShouldRetryUpload'); } goto AX2y1; AX2y1: $this->move($oJLhT, $EerLH['fullPath']); goto S4drQ; L0VA2: $this->uploadChunkTokenAndDeleteToken($EerLH); goto rB4UJ; vBchi: $this->combine($oJLhT); goto L0VA2; n7Q0g: $CnWtd['finished'] = true; goto FEkgs; FkcBG: $CnWtd['preview'] = $this->getDriverFullPath($EerLH['fullPath']); goto n7Q0g; AoYCg: $CnWtd['path'] = $EerLH['fullPath']; goto FkcBG; AnXWP: $CnWtd['data'] = $yPirl; goto AoYCg; n7oI2: $yPirl = $this->repository->addTemp($ZRqAm, $EerLH['path'], $EerLH['name'], $EerLH['size'], empty($EerLH['md5']) ? null : $EerLH['md5']); goto AnXWP; S4drQ: DataFileUploadedEvent::fire(null, $ZRqAm, $EerLH['fullPath']); goto n7oI2; rB4UJ: $A33WR = $this->size($oJLhT); goto RdwCt; FEkgs: } goto pJOo3; pJOo3: } goto lUzHv; IocK3: if (empty($kFc4w['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto IbTKi; gtJyk: $kFc4w = $qHLCM['input']; goto fLOnr; y0WHq: $CnWtd['chunk'] = $kFc4w['chunk']; goto vUUD2; vUUD2: $CnWtd['file'] = $kFc4w['file']; goto BaOZi; KXIul: } private function combine($aYJAK) { goto YD_PT; qrwVG: $oNQ7p = @fopen($SGkWN . $aYJAK, 'wb'); goto CENEK; WY9aC: fclose($oNQ7p); goto KJKVk; CENEK: if (flock($oNQ7p, LOCK_EX)) { for ($MqJHJ = 0;; $MqJHJ++) { if (!$this->localStorage->has($aYJAK . '.' . $MqJHJ)) { break; } $Afv_G = file_get_contents($SGkWN . $aYJAK . '.' . $MqJHJ); fwrite($oNQ7p, $Afv_G); @unlink($SGkWN . $aYJAK . '.' . $MqJHJ); } flock($oNQ7p, LOCK_UN); } goto WY9aC; YD_PT: $SGkWN = config('filesystems.disks.data.root'); goto qrwVG; KJKVk: } }