<?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($fWBvH) { if ($this->localStorage->has($fWBvH)) { return $this->localStorage->get($fWBvH); } return null; } public function size($fWBvH) { return $this->localStorage->size($fWBvH); } public function put($fWBvH, $ohNZt) { $this->localStorage->put($fWBvH, $ohNZt); } public function has($fWBvH) { return $this->localStorage->has($fWBvH); } public function delete($fWBvH) { $this->localStorage->delete($fWBvH); } public function move($wZ0QM, $hKkPV) { $this->localStorage->copy($wZ0QM, $hKkPV); $this->localStorage->delete($wZ0QM); } public function multiPartInit($pmJAc) { goto EjriT; EjriT: $I82X8 = $this->multiPartInitToken($pmJAc); goto p4bVO; lnwIn: return Response::generate(0, 'ok', $I82X8); goto kIcDJ; p4bVO: $this->uploadChunkTokenAndUpdateToken($I82X8); goto lnwIn; kIcDJ: } public function multiPartUpload($pmJAc) { goto TdJ0v; xyxm5: $do_OL = $pmJAc['input']; goto gVW4P; dC6cU: return Response::generate(0, 'ok', $IaeCl); goto TJoPz; pWg1c: if ($IaeCl['chunk'] < $IaeCl['chunks']) { goto YGqLQ; hDAyT: if ($I82X8['chunkUploaded'] == $IaeCl['chunks']) { goto EVjtk; oDY0H: $this->uploadChunkTokenAndDeleteToken($I82X8); goto SNaE7; e4ONC: $IaeCl['preview'] = $this->getDriverFullPath($I82X8['fullPath']); goto XlJnX; qHzxg: $IaeCl['path'] = $I82X8['fullPath']; goto e4ONC; CoI_A: $IaeCl['data'] = $t5kxe; goto qHzxg; XlJnX: $IaeCl['finished'] = true; goto tUl1t; j82o4: DataFileUploadedEvent::fire(null, $IaATa, $I82X8['fullPath']); goto q193l; fXgve: $this->move($w7Kaa, $I82X8['fullPath']); goto j82o4; EVjtk: $this->combine($w7Kaa); goto oDY0H; LpQdQ: if ($KOPVY != $I82X8['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $KOPVY . ',' . $I82X8['size'] . ') ShouldRetryUpload'); } goto fXgve; SNaE7: $KOPVY = $this->size($w7Kaa); goto LpQdQ; q193l: $t5kxe = $this->repository->addTemp($IaATa, $I82X8['path'], $I82X8['name'], $I82X8['size'], empty($I82X8['md5']) ? null : $I82X8['md5']); goto CoI_A; tUl1t: } goto J35AH; PSgfv: $this->localStorage->put($w7Kaa . '.' . $IaeCl['chunk'], $ohNZt); goto pbuRn; AudS1: $IaeCl['finished'] = false; goto hDAyT; YGqLQ: $UdtHk = $IaeCl['file']->getRealPath(); goto z8VxF; z8VxF: if (false === $UdtHk) { $UdtHk = $IaeCl['file']->getPathname(); } goto O3pad; pbuRn: $I82X8['chunkUploaded'] = $IaeCl['chunk'] + 1; goto AiByB; O3pad: $ohNZt = file_get_contents($UdtHk); goto PSgfv; AiByB: $this->uploadChunkTokenAndUpdateToken($I82X8); goto AudS1; J35AH: } goto dC6cU; KMI9P: $w7Kaa = self::DATA_CHUNK . '/data/' . $I82X8['hash']; goto pWg1c; lquU7: $IaeCl = array(); goto kfba4; uTAIX: $IaeCl['file'] = $do_OL['file']; goto KMI9P; SOCFp: $IaeCl['chunks'] = $do_OL['chunks']; goto zTiZu; aPJSx: if (empty($do_OL['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto SOCFp; kfba4: if (!isset($do_OL['chunks'])) { $do_OL['chunks'] = 1; } goto Jr4r2; Jr4r2: if (!isset($do_OL['chunk'])) { $do_OL['chunk'] = 0; } goto aPJSx; TdJ0v: $I82X8 = $this->multiPartInitToken($pmJAc); goto xyxm5; zTiZu: $IaeCl['chunk'] = $do_OL['chunk']; goto uTAIX; gVW4P: $IaATa = $pmJAc['category']; goto lquU7; TJoPz: } private function combine($fWBvH) { goto Jfu66; d7U8K: fclose($cD3KZ); goto FElEH; ehCqg: $cD3KZ = @fopen($eMsN6 . $fWBvH, 'wb'); goto oKsIb; Jfu66: $eMsN6 = config('filesystems.disks.data.root'); goto ehCqg; oKsIb: if (flock($cD3KZ, LOCK_EX)) { for ($JhHfm = 0;; $JhHfm++) { if (!$this->localStorage->has($fWBvH . '.' . $JhHfm)) { break; } $ohNZt = file_get_contents($eMsN6 . $fWBvH . '.' . $JhHfm); fwrite($cD3KZ, $ohNZt); @unlink($eMsN6 . $fWBvH . '.' . $JhHfm); } flock($cD3KZ, LOCK_UN); } goto d7U8K; FElEH: } }