<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Storage; use ModStart\Core\Input\Response; use ModStart\Data\AbstractDataStorage; class FileDataStorage extends AbstractDataStorage { public function init() { } public function get($oU8qf) { if ($this->localStorage->has($oU8qf)) { return $this->localStorage->get($oU8qf); } return null; } public function size($oU8qf) { return $this->localStorage->size($oU8qf); } public function put($oU8qf, $xMSF0) { $this->localStorage->put($oU8qf, $xMSF0); } public function has($oU8qf) { return $this->localStorage->has($oU8qf); } public function delete($oU8qf) { $this->localStorage->delete($oU8qf); } public function move($RNE_j, $Gp4Ek) { $this->localStorage->copy($RNE_j, $Gp4Ek); $this->localStorage->delete($RNE_j); } public function multiPartInit($lyajz) { goto vu_Go; cAwiV: $this->uploadChunkTokenAndUpdateToken($kRdVK); goto N1UVf; vu_Go: $kRdVK = $this->multiPartInitToken($lyajz); goto cAwiV; N1UVf: return Response::generate(0, 'ok', $kRdVK); goto Km8Ll; Km8Ll: } public function multiPartUpload($lyajz) { goto JuAGd; tU3et: $Y0YxF['file'] = $R4txz['file']; goto PTfwq; uxkoE: if (!isset($R4txz['chunks'])) { $R4txz['chunks'] = 1; } goto GKaiv; SNxzK: if (empty($R4txz['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto BUtmh; GgG2w: $KD2ht = $lyajz['category']; goto mq3qe; mq3qe: $Y0YxF = array(); goto uxkoE; giCbU: if ($Y0YxF['chunk'] < $Y0YxF['chunks']) { goto cRdW4; cRdW4: $xMSF0 = file_get_contents($Y0YxF['file']->getRealPath()); goto hekmW; P2uf2: $this->uploadChunkTokenAndUpdateToken($kRdVK); goto VwIXf; hekmW: $this->localStorage->put($NGfHZ . '.' . $Y0YxF['chunk'], $xMSF0); goto RhZUs; RhZUs: $kRdVK['chunkUploaded'] = $Y0YxF['chunk'] + 1; goto P2uf2; VwIXf: $Y0YxF['finished'] = false; goto KwMPo; KwMPo: if ($kRdVK['chunkUploaded'] == $Y0YxF['chunks']) { goto aY0NR; fy531: $Y0YxF['path'] = $kRdVK['fullPath']; goto I0tID; mH5gC: $Y0YxF['finished'] = true; goto LNpSu; aY0NR: $this->combine($NGfHZ); goto RdVaL; RdVaL: $this->uploadChunkTokenAndDeleteToken($kRdVK); goto AQe3z; wkC6e: $Y0YxF['data'] = $xm_zP; goto fy531; ij6aV: $this->move($NGfHZ, $kRdVK['fullPath']); goto QSe5C; I0tID: $Y0YxF['preview'] = $this->getDriverFullPath($kRdVK['fullPath']); goto mH5gC; AQe3z: $usjDu = $this->size($NGfHZ); goto TbDT0; TbDT0: if ($usjDu != $kRdVK['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $usjDu . ',' . $kRdVK['size'] . ')'); } goto ij6aV; QSe5C: $xm_zP = $this->repository->addTemp($KD2ht, $kRdVK['path'], $kRdVK['name'], $kRdVK['size']); goto wkC6e; LNpSu: } goto m_qjo; m_qjo: } goto Dr9sB; JuAGd: $kRdVK = $this->multiPartInitToken($lyajz); goto UiUS_; GKaiv: if (!isset($R4txz['chunk'])) { $R4txz['chunk'] = 0; } goto SNxzK; UiUS_: $R4txz = $lyajz['input']; goto GgG2w; PTfwq: $NGfHZ = self::DATA_CHUNK . '/data/' . $kRdVK['hash']; goto giCbU; Dr9sB: return Response::generate(0, 'ok', $Y0YxF); goto fpl7W; BUtmh: $Y0YxF['chunks'] = $R4txz['chunks']; goto kqF8_; kqF8_: $Y0YxF['chunk'] = $R4txz['chunk']; goto tU3et; fpl7W: } private function combine($oU8qf) { goto T9jIK; uafGu: fclose($wyEfB); goto hAYmN; J5HXl: $wyEfB = @fopen($OdP0C . $oU8qf, 'wb'); goto pmJhT; T9jIK: $OdP0C = config('filesystems.disks.data.root'); goto J5HXl; pmJhT: if (flock($wyEfB, LOCK_EX)) { for ($K3Ni_ = 0;; $K3Ni_++) { if (!$this->localStorage->has($oU8qf . '.' . $K3Ni_)) { break; } $xMSF0 = file_get_contents($OdP0C . $oU8qf . '.' . $K3Ni_); fwrite($wyEfB, $xMSF0); @unlink($OdP0C . $oU8qf . '.' . $K3Ni_); } flock($wyEfB, LOCK_UN); } goto uafGu; hAYmN: } }