<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Traits; use ModStart\Core\Input\Response; use ModStart\Data\Event\DataFileUploadedEvent; trait LocalMultipartUploadTrait { public function multiPartInit($Kp99R) { goto AhTuG; vK7jT: $this->uploadChunkTokenAndUpdateToken($xT5sm); goto fGNi6; AhTuG: $xT5sm = $this->multiPartInitToken($Kp99R); goto vK7jT; fGNi6: return Response::generate(0, 'ok', $xT5sm); goto cHT2y; cHT2y: } public function multiPartUpload($Kp99R) { goto vEp0N; BuoSP: if (empty($H2Do2['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto vc2NW; ajwAX: $EdQjV = array(); goto tgDo2; vEp0N: $xT5sm = $this->multiPartInitToken($Kp99R); goto M9wPT; vc2NW: $EdQjV['chunks'] = $H2Do2['chunks']; goto dwLBR; sDowq: $WECVu = self::DATA_CHUNK . '/data/' . $xT5sm['hash']; goto DV95q; DV95q: if ($EdQjV['chunk'] < $EdQjV['chunks']) { goto ePjaT; TpQ_d: $this->uploadChunkTokenAndUpdateToken($xT5sm); goto RsUrY; lcVlv: if ($xT5sm['chunkUploaded'] == $EdQjV['chunks']) { goto b2pa3; nf_an: $EdQjV['data'] = $hRQWe; goto ZwDgt; fX2xb: DataFileUploadedEvent::fire($this->remoteType, $fVt3n, $xT5sm['fullPath']); goto P8aC_; oyiaZ: if ($OBDDz != $xT5sm['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $OBDDz . ',' . $xT5sm['size'] . ') ShouldRetryUpload'); } goto CO4QJ; jgCNe: $OBDDz = $this->localStorage->size($WECVu); goto oyiaZ; ZwDgt: $EdQjV['path'] = $xT5sm['fullPath']; goto PAqmN; b2pa3: $this->combine($WECVu); goto kZnzG; Qy6Md: $EdQjV['finished'] = true; goto AtDUn; CO4QJ: $this->saveLocalToRemote($WECVu, $xT5sm['fullPath']); goto Z97sc; kZnzG: $this->uploadChunkTokenAndDeleteToken($xT5sm); goto jgCNe; Z97sc: @unlink(public_path($WECVu)); goto fX2xb; P8aC_: $hRQWe = $this->repository->addTemp($fVt3n, $xT5sm['path'], $xT5sm['name'], $xT5sm['size'], empty($xT5sm['md5']) ? null : $xT5sm['md5']); goto nf_an; PAqmN: $EdQjV['preview'] = $this->getDriverFullPath($xT5sm['fullPath']); goto Qy6Md; AtDUn: } goto xraoG; zqb3s: $this->localStorage->put($WECVu . '.' . $EdQjV['chunk'], $rFmqf); goto FuJPN; FuJPN: $xT5sm['chunkUploaded'] = $EdQjV['chunk'] + 1; goto TpQ_d; RsUrY: $EdQjV['finished'] = false; goto lcVlv; ePjaT: $rFmqf = file_get_contents($EdQjV['file']->getRealPath()); goto zqb3s; xraoG: } goto wymFq; vhUY6: $EdQjV['file'] = $H2Do2['file']; goto sDowq; tgDo2: if (!isset($H2Do2['chunks'])) { $H2Do2['chunks'] = 1; } goto v1Otg; dwLBR: $EdQjV['chunk'] = $H2Do2['chunk']; goto vhUY6; wymFq: return Response::generate(0, 'ok', $EdQjV); goto Hx62y; v1Otg: if (!isset($H2Do2['chunk'])) { $H2Do2['chunk'] = 0; } goto BuoSP; M9wPT: $H2Do2 = $Kp99R['input']; goto Qodss; Qodss: $fVt3n = $Kp99R['category']; goto ajwAX; Hx62y: } private function combine($qsQD8) { goto sqPvG; hXosx: $PgWIV = @fopen($VHhEW . $qsQD8, 'wb'); goto b4_sV; b4_sV: 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 VQBTX; VQBTX: fclose($PgWIV); goto mnHw3; sqPvG: $VHhEW = config('filesystems.disks.data.root'); goto hXosx; mnHw3: } }