<?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($qsQD8) { if ($this->localStorage->has($qsQD8)) { return $this->localStorage->get($qsQD8); } return null; } public function size($qsQD8) { return $this->localStorage->size($qsQD8); } public function put($qsQD8, $rFmqf) { $this->localStorage->put($qsQD8, $rFmqf); } public function has($qsQD8) { return $this->localStorage->has($qsQD8); } public function delete($qsQD8) { $this->localStorage->delete($qsQD8); } public function move($S7Ck8, $ygeGW) { $this->localStorage->copy($S7Ck8, $ygeGW); $this->localStorage->delete($S7Ck8); } public function multiPartInit($Kp99R) { goto UCDfo; o_03n: $this->uploadChunkTokenAndUpdateToken($xT5sm); goto fbs5v; UCDfo: $xT5sm = $this->multiPartInitToken($Kp99R); goto o_03n; fbs5v: return Response::generate(0, 'ok', $xT5sm); goto y4Ymd; y4Ymd: } public function multiPartUpload($Kp99R) { goto G2hyv; WtCt7: if (!isset($H2Do2['chunk'])) { $H2Do2['chunk'] = 0; } goto TUyTl; OgQTB: $EdQjV = array(); goto U8NU4; BSICa: $WECVu = self::DATA_CHUNK . '/data/' . $xT5sm['hash']; goto hDpq0; TUyTl: if (empty($H2Do2['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto CnP30; G2hyv: $xT5sm = $this->multiPartInitToken($Kp99R); goto fp2FG; fp2FG: $H2Do2 = $Kp99R['input']; goto hzdMd; n6fO0: $EdQjV['file'] = $H2Do2['file']; goto BSICa; CnP30: $EdQjV['chunks'] = $H2Do2['chunks']; goto xev2N; hzdMd: $fVt3n = $Kp99R['category']; goto OgQTB; hDpq0: if ($EdQjV['chunk'] < $EdQjV['chunks']) { goto KeXmi; suIsx: $EdQjV['finished'] = false; goto H71T9; TVp3e: $this->localStorage->put($WECVu . '.' . $EdQjV['chunk'], $rFmqf); goto pk3d6; XNMhj: $rFmqf = file_get_contents($Mc7y1); goto TVp3e; KeXmi: $Mc7y1 = $EdQjV['file']->getRealPath(); goto sprmJ; H71T9: if ($xT5sm['chunkUploaded'] == $EdQjV['chunks']) { goto F3TO6; F3TO6: $this->combine($WECVu); goto ORkc7; ca_PC: $OBDDz = $this->size($WECVu); goto t2TY7; t2TY7: if ($OBDDz != $xT5sm['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $OBDDz . ',' . $xT5sm['size'] . ') ShouldRetryUpload'); } goto ULBAI; ORkc7: $this->uploadChunkTokenAndDeleteToken($xT5sm); goto ca_PC; dcu1k: $EdQjV['data'] = $hRQWe; goto a3w5E; a3w5E: $EdQjV['path'] = $xT5sm['fullPath']; goto UN4ab; ULBAI: $this->move($WECVu, $xT5sm['fullPath']); goto FpgBb; KpjJo: $EdQjV['finished'] = true; goto du2GM; UN4ab: $EdQjV['preview'] = $this->getDriverFullPath($xT5sm['fullPath']); goto KpjJo; FpgBb: DataFileUploadedEvent::fire(null, $fVt3n, $xT5sm['fullPath']); goto m0wpt; m0wpt: $hRQWe = $this->repository->addTemp($fVt3n, $xT5sm['path'], $xT5sm['name'], $xT5sm['size'], empty($xT5sm['md5']) ? null : $xT5sm['md5']); goto dcu1k; du2GM: } goto IaA1w; sprmJ: if (false === $Mc7y1) { $Mc7y1 = $EdQjV['file']->getPathname(); } goto XNMhj; mz1tr: $this->uploadChunkTokenAndUpdateToken($xT5sm); goto suIsx; pk3d6: $xT5sm['chunkUploaded'] = $EdQjV['chunk'] + 1; goto mz1tr; IaA1w: } goto QCDkB; U8NU4: if (!isset($H2Do2['chunks'])) { $H2Do2['chunks'] = 1; } goto WtCt7; QCDkB: return Response::generate(0, 'ok', $EdQjV); goto B9FJo; xev2N: $EdQjV['chunk'] = $H2Do2['chunk']; goto n6fO0; B9FJo: } private function combine($qsQD8) { goto JD1b4; dbvEp: if (flock($PgWIV, LOCK_EX)) { for ($eQWJY = 0;; $eQWJY++) { if (!$this->localStorage->has($qsQD8 . '.' . $eQWJY)) { break; } $rFmqf = file_get_contents($VHhEW . $qsQD8 . '.' . $eQWJY); fwrite($PgWIV, $rFmqf); @unlink($VHhEW . $qsQD8 . '.' . $eQWJY); } flock($PgWIV, LOCK_UN); } goto hxbfn; JD1b4: $VHhEW = config('filesystems.disks.data.root'); goto gOa2I; gOa2I: $PgWIV = @fopen($VHhEW . $qsQD8, 'wb'); goto dbvEp; hxbfn: fclose($PgWIV); goto KuMha; KuMha: } }