<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Data\Traits; use ModStart\Core\Input\Response; use ModStart\Data\Event\DataFileUploadedEvent; trait LocalMultipartUploadTrait { public function multiPartInit($AXgEz) { goto q03f6; rZiT8: return Response::generate(0, 'ok', $uBuY2); goto nP5II; MRzHX: $this->uploadChunkTokenAndUpdateToken($uBuY2); goto rZiT8; q03f6: $uBuY2 = $this->multiPartInitToken($AXgEz); goto MRzHX; nP5II: } public function multiPartUpload($AXgEz) { goto wKQyl; ISctp: $zonFp['file'] = $sYsuI['file']; goto ro00w; VMG16: if (!isset($sYsuI['chunk'])) { $sYsuI['chunk'] = 0; } goto SGUIE; s_cBt: if (!isset($sYsuI['chunks'])) { $sYsuI['chunks'] = 1; } goto VMG16; wKQyl: $uBuY2 = $this->multiPartInitToken($AXgEz); goto hIXvB; vzYbM: $zonFp['chunk'] = $sYsuI['chunk']; goto ISctp; ro00w: $GIMON = self::DATA_CHUNK . '/data/' . $uBuY2['hash']; goto gBHi4; gBHi4: if ($zonFp['chunk'] < $zonFp['chunks']) { goto SBhMi; nwAA0: $this->uploadChunkTokenAndUpdateToken($uBuY2); goto zmnTa; nRzET: if ($uBuY2['chunkUploaded'] == $zonFp['chunks']) { goto m_ALG; wzlqi: $this->saveLocalToRemote($GIMON, $uBuY2['fullPath']); goto v4T1X; m_ALG: $this->combine($GIMON); goto fWQmw; CRwUj: $zonFp['preview'] = $this->getDriverFullPath($uBuY2['fullPath']); goto rddBr; rddBr: $zonFp['finished'] = true; goto IA1xX; YYfE9: DataFileUploadedEvent::fire($this->remoteType, $NU9Ix, $uBuY2['fullPath']); goto p87WY; p87WY: $kwGlo = $this->repository->addTemp($NU9Ix, $uBuY2['path'], $uBuY2['name'], $uBuY2['size'], empty($uBuY2['md5']) ? null : $uBuY2['md5']); goto I1LEF; I1LEF: $zonFp['data'] = $kwGlo; goto D1w8h; v4T1X: @unlink(public_path($GIMON)); goto YYfE9; fWQmw: $this->uploadChunkTokenAndDeleteToken($uBuY2); goto r1meA; m66nw: if ($K2nkR != $uBuY2['size']) { return Response::generate(-1, 'MultiPartUpload combile file failed (' . $K2nkR . ',' . $uBuY2['size'] . ') ShouldRetryUpload'); } goto wzlqi; r1meA: $K2nkR = $this->localStorage->size($GIMON); goto m66nw; D1w8h: $zonFp['path'] = $uBuY2['fullPath']; goto CRwUj; IA1xX: } goto rnSnY; zmnTa: $zonFp['finished'] = false; goto nRzET; Bu02Q: $uBuY2['chunkUploaded'] = $zonFp['chunk'] + 1; goto nwAA0; SBhMi: $BWI89 = file_get_contents($zonFp['file']->getRealPath()); goto Sl8Pm; Sl8Pm: $this->localStorage->put($GIMON . '.' . $zonFp['chunk'], $BWI89); goto Bu02Q; rnSnY: } goto bAK17; Wn0tx: $zonFp = array(); goto s_cBt; bAK17: return Response::generate(0, 'ok', $zonFp); goto ZwBYe; z9e20: $NU9Ix = $AXgEz['category']; goto Wn0tx; SGUIE: if (empty($sYsuI['file'])) { return Response::generateError('MultiPartUpload file empty'); } goto LaXhz; LaXhz: $zonFp['chunks'] = $sYsuI['chunks']; goto vzYbM; hIXvB: $sYsuI = $AXgEz['input']; goto z9e20; ZwBYe: } private function combine($Jtt5u) { goto tEoLo; vcUD9: fclose($EIBx3); goto E6dYA; t_9z0: $EIBx3 = @fopen($oIZ4g . $Jtt5u, 'wb'); goto wuGeH; wuGeH: if (flock($EIBx3, LOCK_EX)) { for ($tMyPy = 0;; $tMyPy++) { if (!$this->localStorage->has($Jtt5u . '.' . $tMyPy)) { break; } $BWI89 = file_get_contents($oIZ4g . $Jtt5u . '.' . $tMyPy); fwrite($EIBx3, $BWI89); @unlink($oIZ4g . $Jtt5u . '.' . $tMyPy); } flock($EIBx3, LOCK_UN); } goto vcUD9; tEoLo: $oIZ4g = config('filesystems.disks.data.root'); goto t_9z0; E6dYA: } }