<?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($Jtt5u) { if ($this->localStorage->has($Jtt5u)) { return $this->localStorage->get($Jtt5u); } return null; } public function size($Jtt5u) { return $this->localStorage->size($Jtt5u); } public function put($Jtt5u, $BWI89) { $this->localStorage->put($Jtt5u, $BWI89); } public function has($Jtt5u) { return $this->localStorage->has($Jtt5u); } public function delete($Jtt5u) { $this->localStorage->delete($Jtt5u); } public function move($KXoNz, $kn8dk) { $this->localStorage->copy($KXoNz, $kn8dk); $this->localStorage->delete($KXoNz); } public function multiPartInit($AXgEz) { goto hxKZN; hxKZN: $uBuY2 = $this->multiPartInitToken($AXgEz); goto og0Zx; og0Zx: $this->uploadChunkTokenAndUpdateToken($uBuY2); goto f0TGi; f0TGi: return Response::generate(0, 'ok', $uBuY2); goto NmJVQ; NmJVQ: } public function multiPartUpload($AXgEz) { goto Vg888; pECej: if (empty($sYsuI['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto qNdTh; jvUTi: if ($zonFp['chunk'] < $zonFp['chunks']) { goto HhU_b; iIWjo: if ($uBuY2['chunkUploaded'] == $zonFp['chunks']) { goto Mfvjc; ulQqC: $K2nkR = $this->size($GIMON); goto C0GbD; SQdax: $this->move($GIMON, $uBuY2['fullPath']); goto x8hJs; SktMe: $kwGlo = $this->repository->addTemp($NU9Ix, $uBuY2['path'], $uBuY2['name'], $uBuY2['size'], empty($uBuY2['md5']) ? null : $uBuY2['md5']); goto QxWCl; Mfvjc: $this->combine($GIMON); goto WP92M; SRysn: $zonFp['finished'] = true; goto dN6eW; hpzhC: $zonFp['path'] = $uBuY2['fullPath']; goto xZsfu; WP92M: $this->uploadChunkTokenAndDeleteToken($uBuY2); goto ulQqC; QxWCl: $zonFp['data'] = $kwGlo; goto hpzhC; x8hJs: DataFileUploadedEvent::fire(null, $NU9Ix, $uBuY2['fullPath']); goto SktMe; C0GbD: if ($K2nkR != $uBuY2['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $K2nkR . ',' . $uBuY2['size'] . ') ShouldRetryUpload'); } goto SQdax; xZsfu: $zonFp['preview'] = $this->getDriverFullPath($uBuY2['fullPath']); goto SRysn; dN6eW: } goto aMlwb; HhU_b: $qwcyu = $zonFp['file']->getRealPath(); goto XlvYk; uQ8FI: $this->uploadChunkTokenAndUpdateToken($uBuY2); goto RVfQS; T1mFr: $BWI89 = file_get_contents($qwcyu); goto MADCW; XlvYk: if (false === $qwcyu) { $qwcyu = $zonFp['file']->getPathname(); } goto T1mFr; MADCW: $this->localStorage->put($GIMON . '.' . $zonFp['chunk'], $BWI89); goto T9ixs; RVfQS: $zonFp['finished'] = false; goto iIWjo; T9ixs: $uBuY2['chunkUploaded'] = $zonFp['chunk'] + 1; goto uQ8FI; aMlwb: } goto r06OW; rfFou: $NU9Ix = $AXgEz['category']; goto ozj8f; JnhNx: $zonFp['file'] = $sYsuI['file']; goto tY3e1; tY3e1: $GIMON = self::DATA_CHUNK . '/data/' . $uBuY2['hash']; goto jvUTi; JYr0O: $sYsuI = $AXgEz['input']; goto rfFou; Vg888: $uBuY2 = $this->multiPartInitToken($AXgEz); goto JYr0O; ozj8f: $zonFp = array(); goto Xhnoo; gRmT9: if (!isset($sYsuI['chunk'])) { $sYsuI['chunk'] = 0; } goto pECej; l8zIE: $zonFp['chunk'] = $sYsuI['chunk']; goto JnhNx; Xhnoo: if (!isset($sYsuI['chunks'])) { $sYsuI['chunks'] = 1; } goto gRmT9; qNdTh: $zonFp['chunks'] = $sYsuI['chunks']; goto l8zIE; r06OW: return Response::generate(0, 'ok', $zonFp); goto rKVt5; rKVt5: } private function combine($Jtt5u) { goto TXTqD; GLMfF: fclose($EIBx3); goto qGEiX; B1dye: if (flock($EIBx3, LOCK_EX)) { for ($tMyPy = 0;; $tMyPy++) { if (!$this->localStorage->has($Jtt5u . '.' . $tMyPy)) { break; } $BWI89 = file_get_contents($oIZ4g . $Jtt5u . '.' . $tMyPy); fwrite($EIBx3, $BWI89); @unlink($oIZ4g . $Jtt5u . '.' . $tMyPy); } flock($EIBx3, LOCK_UN); } goto GLMfF; TXTqD: $oIZ4g = config('filesystems.disks.data.root'); goto kKOAx; kKOAx: $EIBx3 = @fopen($oIZ4g . $Jtt5u, 'wb'); goto B1dye; qGEiX: } }