<?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($yHf3t) { if ($this->localStorage->has($yHf3t)) { return $this->localStorage->get($yHf3t); } return null; } public function size($yHf3t) { return $this->localStorage->size($yHf3t); } public function put($yHf3t, $cgjRu) { $this->localStorage->put($yHf3t, $cgjRu); } public function has($yHf3t) { return $this->localStorage->has($yHf3t); } public function delete($yHf3t) { $this->localStorage->delete($yHf3t); } public function move($KUvwa, $QCEgc) { $this->localStorage->copy($KUvwa, $QCEgc); $this->localStorage->delete($KUvwa); } public function multiPartInit($oK4I3) { goto yE5Tc; c3TUQ: $this->uploadChunkTokenAndUpdateToken($R0P9s); goto sXBB9; sXBB9: return Response::generate(0, 'ok', $R0P9s); goto I2Dp2; yE5Tc: $R0P9s = $this->multiPartInitToken($oK4I3); goto c3TUQ; I2Dp2: } public function multiPartUpload($oK4I3) { goto UC84Y; wejUc: $W8QzG = $oK4I3['category']; goto r8C6O; ux_o8: $SjN8A['file'] = $HoUFw['file']; goto LEg1s; Pm4z_: $SjN8A['chunks'] = $HoUFw['chunks']; goto J5dvo; bcrFF: if (!isset($HoUFw['chunks'])) { $HoUFw['chunks'] = 1; } goto Bvu7C; gsIhC: if ($SjN8A['chunk'] < $SjN8A['chunks']) { goto QJxsK; XMRnH: $this->localStorage->put($qNxT5 . '.' . $SjN8A['chunk'], $cgjRu); goto qOKcl; uAeQk: $this->uploadChunkTokenAndUpdateToken($R0P9s); goto RIPyf; QJxsK: $v2qOY = $SjN8A['file']->getRealPath(); goto iS846; qOKcl: $R0P9s['chunkUploaded'] = $SjN8A['chunk'] + 1; goto uAeQk; SnWEF: if ($R0P9s['chunkUploaded'] == $SjN8A['chunks']) { goto HNe0Y; PhBKI: $w6t6K = $this->size($qNxT5); goto vJOfv; kfG7H: $SjN8A['path'] = $R0P9s['fullPath']; goto HFas0; uyurt: $xp1IY = $this->repository->addTemp($W8QzG, $R0P9s['path'], $R0P9s['name'], $R0P9s['size'], empty($R0P9s['md5']) ? null : $R0P9s['md5']); goto kwJEC; vJOfv: if ($w6t6K != $R0P9s['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $w6t6K . ',' . $R0P9s['size'] . ') ShouldRetryUpload'); } goto AhY84; kwJEC: $SjN8A['data'] = $xp1IY; goto kfG7H; HFas0: $SjN8A['preview'] = $this->getDriverFullPath($R0P9s['fullPath']); goto l9hNS; HNe0Y: $this->combine($qNxT5); goto nI77h; nI77h: $this->uploadChunkTokenAndDeleteToken($R0P9s); goto PhBKI; l9hNS: $SjN8A['finished'] = true; goto bgPEy; LQ0ed: DataFileUploadedEvent::fire(null, $W8QzG, $R0P9s['fullPath']); goto uyurt; AhY84: $this->move($qNxT5, $R0P9s['fullPath']); goto LQ0ed; bgPEy: } goto YfM9w; iS846: if (false === $v2qOY) { $v2qOY = $SjN8A['file']->getPathname(); } goto t3VZP; t3VZP: $cgjRu = file_get_contents($v2qOY); goto XMRnH; RIPyf: $SjN8A['finished'] = false; goto SnWEF; YfM9w: } goto VK10a; Bvu7C: if (!isset($HoUFw['chunk'])) { $HoUFw['chunk'] = 0; } goto geREU; UC84Y: $R0P9s = $this->multiPartInitToken($oK4I3); goto zwVg5; r8C6O: $SjN8A = array(); goto bcrFF; LEg1s: $qNxT5 = self::DATA_CHUNK . '/data/' . $R0P9s['hash']; goto gsIhC; geREU: if (empty($HoUFw['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto Pm4z_; VK10a: return Response::generate(0, 'ok', $SjN8A); goto EmEyp; J5dvo: $SjN8A['chunk'] = $HoUFw['chunk']; goto ux_o8; zwVg5: $HoUFw = $oK4I3['input']; goto wejUc; EmEyp: } private function combine($yHf3t) { goto HaL3c; B3lfD: if (flock($tauHV, LOCK_EX)) { for ($UCcmA = 0;; $UCcmA++) { if (!$this->localStorage->has($yHf3t . '.' . $UCcmA)) { break; } $cgjRu = file_get_contents($XhKKF . $yHf3t . '.' . $UCcmA); fwrite($tauHV, $cgjRu); @unlink($XhKKF . $yHf3t . '.' . $UCcmA); } flock($tauHV, LOCK_UN); } goto ZveD1; I60vN: $tauHV = @fopen($XhKKF . $yHf3t, 'wb'); goto B3lfD; ZveD1: fclose($tauHV); goto EIt2g; HaL3c: $XhKKF = config('filesystems.disks.data.root'); goto I60vN; EIt2g: } }