<?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($WF06r) { if ($this->localStorage->has($WF06r)) { return $this->localStorage->get($WF06r); } return null; } public function size($WF06r) { return $this->localStorage->size($WF06r); } public function put($WF06r, $gP2DQ) { $this->localStorage->put($WF06r, $gP2DQ); } public function has($WF06r) { return $this->localStorage->has($WF06r); } public function delete($WF06r) { $this->localStorage->delete($WF06r); } public function move($E_44J, $cJXa5) { $this->localStorage->copy($E_44J, $cJXa5); $this->localStorage->delete($E_44J); } public function multiPartInit($mattM) { goto aWRHl; DK278: return Response::generate(0, 'ok', $faQ3n); goto CfTJo; aWRHl: $faQ3n = $this->multiPartInitToken($mattM); goto fCrbI; fCrbI: $this->uploadChunkTokenAndUpdateToken($faQ3n); goto DK278; CfTJo: } public function multiPartUpload($mattM) { goto lCsz1; K5skO: $dTnlu['file'] = $vfMTB['file']; goto MZoMD; RQj0Q: $PW0Jg = $mattM['category']; goto WkSRq; TrZ9e: $dTnlu['chunk'] = $vfMTB['chunk']; goto K5skO; CBqgp: if (empty($vfMTB['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto kG6mH; Jx2y0: if ($dTnlu['chunk'] < $dTnlu['chunks']) { goto pQ_SG; HCOgR: $this->uploadChunkTokenAndUpdateToken($faQ3n); goto tRh7p; pQ_SG: $bW0Md = $dTnlu['file']->getRealPath(); goto QCh0T; J0xE7: if ($faQ3n['chunkUploaded'] == $dTnlu['chunks']) { goto bPhfu; DP2Vu: $this->move($g5mOK, $faQ3n['fullPath']); goto cOmD6; V93Bj: $dTnlu['path'] = $faQ3n['fullPath']; goto DZZZu; cOmD6: DataFileUploadedEvent::fire(null, $PW0Jg, $faQ3n['fullPath']); goto TDQR_; W3Xcy: if ($LxBwP != $faQ3n['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $LxBwP . ',' . $faQ3n['size'] . ') ShouldRetryUpload'); } goto DP2Vu; S1bQK: $dTnlu['data'] = $EnSJE; goto V93Bj; DZZZu: $dTnlu['preview'] = $this->getDriverFullPath($faQ3n['fullPath']); goto Hsn39; TDQR_: $EnSJE = $this->repository->addTemp($PW0Jg, $faQ3n['path'], $faQ3n['name'], $faQ3n['size'], empty($faQ3n['md5']) ? null : $faQ3n['md5']); goto S1bQK; Hsn39: $dTnlu['finished'] = true; goto R_B22; Qd78F: $LxBwP = $this->size($g5mOK); goto W3Xcy; bPhfu: $this->combine($g5mOK); goto dUkGo; dUkGo: $this->uploadChunkTokenAndDeleteToken($faQ3n); goto Qd78F; R_B22: } goto InVNF; tRh7p: $dTnlu['finished'] = false; goto J0xE7; xvr5U: $gP2DQ = file_get_contents($bW0Md); goto IhvPn; QCh0T: if (false === $bW0Md) { $bW0Md = $dTnlu['file']->getPathname(); } goto xvr5U; IhvPn: $this->localStorage->put($g5mOK . '.' . $dTnlu['chunk'], $gP2DQ); goto bim3g; bim3g: $faQ3n['chunkUploaded'] = $dTnlu['chunk'] + 1; goto HCOgR; InVNF: } goto W0m1G; WkSRq: $dTnlu = array(); goto M_zk1; lCsz1: $faQ3n = $this->multiPartInitToken($mattM); goto x8aRo; M_zk1: if (!isset($vfMTB['chunks'])) { $vfMTB['chunks'] = 1; } goto keHeQ; x8aRo: $vfMTB = $mattM['input']; goto RQj0Q; kG6mH: $dTnlu['chunks'] = $vfMTB['chunks']; goto TrZ9e; W0m1G: return Response::generate(0, 'ok', $dTnlu); goto XVmvt; keHeQ: if (!isset($vfMTB['chunk'])) { $vfMTB['chunk'] = 0; } goto CBqgp; MZoMD: $g5mOK = self::DATA_CHUNK . '/data/' . $faQ3n['hash']; goto Jx2y0; XVmvt: } private function combine($WF06r) { goto EJW6O; SolhU: fclose($jF2wW); goto MEUaE; EJW6O: $Bhs5s = config('filesystems.disks.data.root'); goto qO28Y; v2H5A: if (flock($jF2wW, LOCK_EX)) { for ($jqibn = 0;; $jqibn++) { if (!$this->localStorage->has($WF06r . '.' . $jqibn)) { break; } $gP2DQ = file_get_contents($Bhs5s . $WF06r . '.' . $jqibn); fwrite($jF2wW, $gP2DQ); @unlink($Bhs5s . $WF06r . '.' . $jqibn); } flock($jF2wW, LOCK_UN); } goto SolhU; qO28Y: $jF2wW = @fopen($Bhs5s . $WF06r, 'wb'); goto v2H5A; MEUaE: } }