aliyun / alibabacloud-php-sdk

36 stars 18 forks source link

imm-20200930 SDK createFileCompressionTask 报错 #35

Closed ChinaMoli closed 2 months ago

ChinaMoli commented 2 months ago

问题描述

由于 SDK 将参数通过 URL Query 传递(问题代码),导致当 URL 长度过长被重置请求。

错误日志

cURL error 56: OpenSSL SSL_read: Connection reset by peer, errno 104 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://imm.cn-hangzhou.aliyuncs.com/?CompressedFormat=zip&ProjectName=xxxxxx&Sources=xxxxxxxxxx

复现代码

<?php

declare(strict_types=1);

use AlibabaCloud\SDK\Imm\V20200930\Imm;
use AlibabaCloud\SDK\Imm\V20200930\Models\CreateFileCompressionTaskRequest;
use AlibabaCloud\SDK\Imm\V20200930\Models\CreateFileCompressionTaskRequest\sources;
use Darabonba\OpenApi\Models\Config;

require __DIR__ . '/vendor/autoload.php';

$bucket = 'your-oss-bucket';
$accessKeyId = '';
$accessKeySecret = '';
$projectName = '';
$endpoint = '';

$client = new Imm(new Config([
    'accessKeyId' => $accessKeyId,
    'accessKeySecret' => $accessKeySecret,
    'endpoint' => $endpoint,
]));

$filepath = "oss://{$bucket}/test.txt";
$sources = [];
for ($i = 0; $i < 5000; $i++) {
    $sources[] = new sources([
        'URI' => $filepath,
        'alias' => 'alias_' . $i,
        'mode' => 'fullname',
    ]);
}

$request = new CreateFileCompressionTaskRequest();
$request->projectName = $projectName;
$request->sources = $sources;
$request->targetURI = "oss://{$bucket}/test.zip";
$request->compressedFormat = 'zip';

$client->createFileCompressionTask($request);

版本号

ChinaMoli commented 2 months ago

问题已解决,当 Sources 文件超过 200 时,需要使用 SourceManifestURI 字段传递