支持分片文件上传

master
elf@home 5 years ago
parent 6b675aa345
commit 8d6c547468

@ -322,15 +322,14 @@ class GameSourceService {
];
}
public function uploadPackage($localFilePath, $distFilePath, $isDeleteLocal = false)
public function uploadPackage($localFilePath, $distFilePath, $isDeleteLocal = false, $isChunk = false)
{
if (get_tool_status('oss_storage') == 1) {
$ossService = new OssService();
$result = $ossService->upload($localFilePath, $distFilePath);
if ($isDeleteLocal && file_exists($localFilePath)) {
@unlink($localFilePath);
if ($isChunk) {
return $this->uploadPackageChunk($localFilePath, $distFilePath, $isDeleteLocal);
} else {
return $this->uploadPackageOnce($localFilePath, $distFilePath, $isDeleteLocal);
}
return $result;
} else {
// 不上传OSS等第三方服务器
return [
@ -342,6 +341,40 @@ class GameSourceService {
];
}
}
public function uploadPackageChunk($localFilePath, $distFilePath, $isDeleteLocal = false)
{
$client = new Client([
'base_uri' => C('UPLOAD_SERVER_URL'),
'timeout' => 10.0,
]);
$response = $client->post('/upload', [
'verify' => false,
'form_params' => [
'file' => $gameId,
'dist' => $distFilePath,
'is_delete_local' => 0,
]
]);
$result = (string)$response->getBody();
$result = json_decode($result, true);
if (!$result) {
return [
'status' => false,
'message' => '请求打包失败',
];
}
return $result;
}
public function uploadPackageOnce($localFilePath, $distFilePath, $isDeleteLocal = false)
{
$ossService = new OssService();
$result = $ossService->upload($localFilePath, $distFilePath);
if ($isDeleteLocal && file_exists($localFilePath)) {
@unlink($localFilePath);
}
return $result;
}
//生成游戏渠道plist文件
public function createPlist($params)

Loading…
Cancel
Save