<?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($sCmIC) { if ($this->localStorage->has($sCmIC)) { return $this->localStorage->get($sCmIC); } return null; } public function size($sCmIC) { return $this->localStorage->size($sCmIC); } public function put($sCmIC, $LTC5O) { $this->localStorage->put($sCmIC, $LTC5O); } public function has($sCmIC) { return $this->localStorage->has($sCmIC); } public function delete($sCmIC) { $this->localStorage->delete($sCmIC); } public function move($FtI8I, $hjIzo) { $this->localStorage->copy($FtI8I, $hjIzo); $this->localStorage->delete($FtI8I); } public function multiPartInit($pFM9U) { goto szelD; Rh_66: $this->uploadChunkTokenAndUpdateToken($K6b7B); goto n78Ml; szelD: $K6b7B = $this->multiPartInitToken($pFM9U); goto Rh_66; n78Ml: return Response::generate(0, 'ok', $K6b7B); goto FXBYf; FXBYf: } public function multiPartUpload($pFM9U) { goto Gb_Cy; ejQ39: if (empty($TG2we['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto yaGBa; KgfQz: $Sj05q = array(); goto XolqZ; XolqZ: if (!isset($TG2we['chunks'])) { $TG2we['chunks'] = 1; } goto geGmw; Gb_Cy: $K6b7B = $this->multiPartInitToken($pFM9U); goto YnIyk; SB5dr: if ($Sj05q['chunk'] < $Sj05q['chunks']) { goto QRSEh; YJG3d: $K6b7B['chunkUploaded'] = $Sj05q['chunk'] + 1; goto r21Lj; bkml5: if ($K6b7B['chunkUploaded'] == $Sj05q['chunks']) { goto DRvQ7; BbFvM: $Sj05q['preview'] = $this->getDriverFullPath($K6b7B['fullPath']); goto Y2d38; v0tX3: $this->move($rcRe8, $K6b7B['fullPath']); goto NtgMp; K6O24: if ($QaVLR != $K6b7B['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $QaVLR . ',' . $K6b7B['size'] . ') ShouldRetryUpload'); } goto v0tX3; Y2d38: $Sj05q['finished'] = true; goto zcbkl; NtgMp: DataFileUploadedEvent::fire(null, $FVUIh, $K6b7B['fullPath']); goto li9i5; li9i5: $tk0m6 = $this->repository->addTemp($FVUIh, $K6b7B['path'], $K6b7B['name'], $K6b7B['size'], empty($K6b7B['md5']) ? null : $K6b7B['md5']); goto VPq5v; HhmSr: $Sj05q['path'] = $K6b7B['fullPath']; goto BbFvM; Tj2mm: $QaVLR = $this->size($rcRe8); goto K6O24; eBqdD: $this->uploadChunkTokenAndDeleteToken($K6b7B); goto Tj2mm; DRvQ7: $this->combine($rcRe8); goto eBqdD; VPq5v: $Sj05q['data'] = $tk0m6; goto HhmSr; zcbkl: } goto sjtXA; QRSEh: $PhYE_ = $Sj05q['file']->getRealPath(); goto hUS0M; hUS0M: if (false === $PhYE_) { $PhYE_ = $Sj05q['file']->getPathname(); } goto Ila8w; Ila8w: $LTC5O = file_get_contents($PhYE_); goto KakKh; e2DZZ: $Sj05q['finished'] = false; goto bkml5; r21Lj: $this->uploadChunkTokenAndUpdateToken($K6b7B); goto e2DZZ; KakKh: $this->localStorage->put($rcRe8 . '.' . $Sj05q['chunk'], $LTC5O); goto YJG3d; sjtXA: } goto YFfg8; yaGBa: $Sj05q['chunks'] = $TG2we['chunks']; goto mpNmW; oELSV: $Sj05q['file'] = $TG2we['file']; goto erWJv; YFfg8: return Response::generate(0, 'ok', $Sj05q); goto jGDVY; erWJv: $rcRe8 = self::DATA_CHUNK . '/data/' . $K6b7B['hash']; goto SB5dr; mpNmW: $Sj05q['chunk'] = $TG2we['chunk']; goto oELSV; YnIyk: $TG2we = $pFM9U['input']; goto flwEF; flwEF: $FVUIh = $pFM9U['category']; goto KgfQz; geGmw: if (!isset($TG2we['chunk'])) { $TG2we['chunk'] = 0; } goto ejQ39; jGDVY: } private function combine($sCmIC) { goto RScjz; hEGDE: if (flock($OKHV6, LOCK_EX)) { for ($Xn_Rr = 0;; $Xn_Rr++) { if (!$this->localStorage->has($sCmIC . '.' . $Xn_Rr)) { break; } $LTC5O = file_get_contents($RFcbL . $sCmIC . '.' . $Xn_Rr); fwrite($OKHV6, $LTC5O); @unlink($RFcbL . $sCmIC . '.' . $Xn_Rr); } flock($OKHV6, LOCK_UN); } goto FSSt3; FSSt3: fclose($OKHV6); goto tHaTT; Yvs62: $OKHV6 = @fopen($RFcbL . $sCmIC, 'wb'); goto hEGDE; RScjz: $RFcbL = config('filesystems.disks.data.root'); goto Yvs62; tHaTT: } }