<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Traits; use ModStart\Core\Input\Response; use ModStart\Data\Event\DataFileUploadedEvent; trait LocalMultipartUploadTrait { public function multiPartInit($oK4I3) { goto rUR48; EDuBN: return Response::generate(0, 'ok', $R0P9s); goto Hr3QQ; rUR48: $R0P9s = $this->multiPartInitToken($oK4I3); goto LK6V4; LK6V4: $this->uploadChunkTokenAndUpdateToken($R0P9s); goto EDuBN; Hr3QQ: } public function multiPartUpload($oK4I3) { goto O5J8_; x5sWU: if (!isset($HoUFw['chunk'])) { $HoUFw['chunk'] = 0; } goto r7ryN; SQdGV: if (!isset($HoUFw['chunks'])) { $HoUFw['chunks'] = 1; } goto x5sWU; O5J8_: $R0P9s = $this->multiPartInitToken($oK4I3); goto u6VwH; Xlh4t: $SjN8A = array(); goto SQdGV; b4_f2: if ($SjN8A['chunk'] < $SjN8A['chunks']) { goto pFtSx; dCsyg: $this->localStorage->put($qNxT5 . '.' . $SjN8A['chunk'], $cgjRu); goto V6MkP; pFtSx: $cgjRu = file_get_contents($SjN8A['file']->getRealPath()); goto dCsyg; cE1n4: if ($R0P9s['chunkUploaded'] == $SjN8A['chunks']) { goto U07MA; cKv5s: $w6t6K = $this->localStorage->size($qNxT5); goto s1htc; vbHfI: $xp1IY = $this->repository->addTemp($W8QzG, $R0P9s['path'], $R0P9s['name'], $R0P9s['size'], empty($R0P9s['md5']) ? null : $R0P9s['md5']); goto F3FX3; U07MA: $this->combine($qNxT5); goto Rtwna; Rtwna: $this->uploadChunkTokenAndDeleteToken($R0P9s); goto cKv5s; K2u2m: @unlink(public_path($qNxT5)); goto aq7ni; ChsJP: $SjN8A['path'] = $R0P9s['fullPath']; goto lHF1M; s1htc: if ($w6t6K != $R0P9s['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $w6t6K . ',' . $R0P9s['size'] . ') ShouldRetryUpload'); } goto HELcR; aq7ni: DataFileUploadedEvent::fire($this->remoteType, $W8QzG, $R0P9s['fullPath']); goto vbHfI; lHF1M: $SjN8A['preview'] = $this->getDriverFullPath($R0P9s['fullPath']); goto BnSIz; F3FX3: $SjN8A['data'] = $xp1IY; goto ChsJP; BnSIz: $SjN8A['finished'] = true; goto TSytw; HELcR: $this->saveLocalToRemote($qNxT5, $R0P9s['fullPath']); goto K2u2m; TSytw: } goto ibc4q; g8hLi: $this->uploadChunkTokenAndUpdateToken($R0P9s); goto vMwVj; V6MkP: $R0P9s['chunkUploaded'] = $SjN8A['chunk'] + 1; goto g8hLi; vMwVj: $SjN8A['finished'] = false; goto cE1n4; ibc4q: } goto jn0dj; r7ryN: if (empty($HoUFw['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto FZpg4; fl3T2: $qNxT5 = self::DATA_CHUNK . '/data/' . $R0P9s['hash']; goto b4_f2; gmXII: $SjN8A['file'] = $HoUFw['file']; goto fl3T2; ly7ct: $W8QzG = $oK4I3['category']; goto Xlh4t; u6VwH: $HoUFw = $oK4I3['input']; goto ly7ct; jn0dj: return Response::generate(0, 'ok', $SjN8A); goto t9iKu; FZpg4: $SjN8A['chunks'] = $HoUFw['chunks']; goto MEi7j; MEi7j: $SjN8A['chunk'] = $HoUFw['chunk']; goto gmXII; t9iKu: } private function combine($yHf3t) { goto MZm_L; MZm_L: $XhKKF = config('filesystems.disks.data.root'); goto FLdZt; FLdZt: $tauHV = @fopen($XhKKF . $yHf3t, 'wb'); goto tJd0I; IcfqB: fclose($tauHV); goto eAyXz; tJd0I: 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 IcfqB; eAyXz: } }