<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Traits; use ModStart\Core\Input\Response; use ModStart\Data\Event\DataFileUploadedEvent; trait LocalMultipartUploadTrait { public function multiPartInit($ACVUe) { goto tTwMm; hMXmn: return Response::generate(0, 'ok', $V6wcT); goto wqySe; tTwMm: $V6wcT = $this->multiPartInitToken($ACVUe); goto I89rS; I89rS: $this->uploadChunkTokenAndUpdateToken($V6wcT); goto hMXmn; wqySe: } public function multiPartUpload($ACVUe) { goto lqmbK; KYeBZ: if (empty($vrSVj['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto S2IbQ; bdZjz: if (!isset($vrSVj['chunk'])) { $vrSVj['chunk'] = 0; } goto KYeBZ; lqmbK: $V6wcT = $this->multiPartInitToken($ACVUe); goto dACGV; lZ2wZ: if ($zvN10['chunk'] < $zvN10['chunks']) { goto sqw2s; b2CLk: $V6wcT['chunkUploaded'] = $zvN10['chunk'] + 1; goto aNGiq; sqw2s: $vVYCS = file_get_contents($zvN10['file']->getRealPath()); goto kPGcj; kPGcj: $this->localStorage->put($jUKXr . '.' . $zvN10['chunk'], $vVYCS); goto b2CLk; aNGiq: $this->uploadChunkTokenAndUpdateToken($V6wcT); goto qwgZa; RauCG: if ($V6wcT['chunkUploaded'] == $zvN10['chunks']) { goto DAdnZ; oELcZ: $zvN10['path'] = $V6wcT['fullPath']; goto E02Eh; E02Eh: $zvN10['preview'] = $this->getDriverFullPath($V6wcT['fullPath']); goto aY72h; aY72h: $zvN10['finished'] = true; goto hvDgO; UBpF0: $zo4ek = $this->localStorage->size($jUKXr); goto xJ41t; p7HuM: DataFileUploadedEvent::fire($this->remoteType, $A1ib2, $V6wcT['fullPath']); goto q_tAV; xJ41t: if ($zo4ek != $V6wcT['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $zo4ek . ',' . $V6wcT['size'] . ') ShouldRetryUpload'); } goto FYvUZ; Y3tLm: @unlink(public_path($jUKXr)); goto p7HuM; HKxCa: $zvN10['data'] = $obUh_; goto oELcZ; sx8hq: $this->uploadChunkTokenAndDeleteToken($V6wcT); goto UBpF0; FYvUZ: $this->saveLocalToRemote($jUKXr, $V6wcT['fullPath']); goto Y3tLm; q_tAV: $obUh_ = $this->repository->addTemp($A1ib2, $V6wcT['path'], $V6wcT['name'], $V6wcT['size'], empty($V6wcT['md5']) ? null : $V6wcT['md5']); goto HKxCa; DAdnZ: $this->combine($jUKXr); goto sx8hq; hvDgO: } goto e0JsJ; qwgZa: $zvN10['finished'] = false; goto RauCG; e0JsJ: } goto NgSo6; S2IbQ: $zvN10['chunks'] = $vrSVj['chunks']; goto XF1AF; NgSo6: return Response::generate(0, 'ok', $zvN10); goto ou1vX; lq4Nq: $A1ib2 = $ACVUe['category']; goto IC4gP; iPuG3: $jUKXr = self::DATA_CHUNK . '/data/' . $V6wcT['hash']; goto lZ2wZ; dACGV: $vrSVj = $ACVUe['input']; goto lq4Nq; IC4gP: $zvN10 = array(); goto Nosjp; XF1AF: $zvN10['chunk'] = $vrSVj['chunk']; goto L9WWY; L9WWY: $zvN10['file'] = $vrSVj['file']; goto iPuG3; Nosjp: if (!isset($vrSVj['chunks'])) { $vrSVj['chunks'] = 1; } goto bdZjz; ou1vX: } private function combine($ypGny) { goto GZ7g3; aM6bx: fclose($ejffh); goto a_apY; GZ7g3: $Av85E = config('filesystems.disks.data.root'); goto m3g6c; m3g6c: $ejffh = @fopen($Av85E . $ypGny, 'wb'); goto xrppn; xrppn: if (flock($ejffh, LOCK_EX)) { for ($kM8qX = 0;; $kM8qX++) { if (!$this->localStorage->has($ypGny . '.' . $kM8qX)) { break; } $vVYCS = file_get_contents($Av85E . $ypGny . '.' . $kM8qX); fwrite($ejffh, $vVYCS); @unlink($Av85E . $ypGny . '.' . $kM8qX); } flock($ejffh, LOCK_UN); } goto aM6bx; a_apY: } }