Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exception 'Aws\S3\Exception\S3Exception' with message 'Error parsing response for PutObject: AWS parsing error: Error parsing XML: String could not be parsed as XML' #2293

Closed
StarrySkyDreamer opened this issue Aug 16, 2021 · 3 comments
Assignees
Labels
closed-for-staleness guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@StarrySkyDreamer
Copy link

PHP version 7.4.3
AWS S3 version 3.190.2 - 2021-08-13
code :

<?php
namespace asw;
// Require the Composer autoloader.
require 'vendor/autoload.php';

use Aws\S3\Exception\S3Exception;
use Aws\S3\S3Client;

// Instantiate an Amazon S3 client.
$s3 = new S3Client([
    'version' => 'latest',
        'region' => 'ap-east-1',
        'credentials' => [
            'key' =>'123456',
            'secret' =>'123456'
        ],
       'endpoint' =>'http://192.168.0.125:9000',
        //开启bug调试
        'debug'   => false
]);

// Upload a publicly accessible file. The file size and type are determined by the SDK.
$url = '0.png';
$filename = 'C:/Users/DF5/Pictures/0.png';
try {
    $s3->putObject([
        'Bucket' => 'lvs',
        'Key'    => $url,
        'Body'   => $filename,
        'ACL'    => 'public-read',
    ]);
} catch (S3Exception $e) {
    echo "There was an error uploading the file.\n".$e;
}

There was an error uploading the file.
exception 'Aws\S3\Exception\S3Exception' with message 'Error parsing response for PutObject: AWS parsing error: Error parsing XML: String could not be parsed as XML'

Exception: String could not be parsed as XML in E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\PayloadParserTrait.php:44
Stack trace:
#0 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\PayloadParserTrait.php(44): SimpleXMLElement->__construct('<!doctype html>...')
#1 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\RestXmlParser.php(39): Aws\Api\Parser\RestXmlParser->parseXml(Object(GuzzleHttp\Psr7\Stream), Object(GuzzleHttp\Psr7\Response))
#2 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\RestXmlParser.php(31): Aws\Api\Parser\RestXmlParser->parseMemberFromStream(Object(GuzzleHttp\Psr7\Stream), Object(Aws\Api\StructureShape), Object(GuzzleHttp\Psr7\Response))
#3 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\AbstractRestParser.php(63): Aws\Api\Parser\RestXmlParser->payload(Object(GuzzleHttp\Psr7\Response), Object(Aws\Api\StructureShape), Array)
#4 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\RetryableMalformedResponseParser.php(37): Aws\Api\Parser\AbstractRestParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#5 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\AmbiguousSuccessParser.php(69): Aws\S3\RetryableMalformedResponseParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#6 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\GetBucketLocationParser.php(29): Aws\S3\AmbiguousSuccessParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#7 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\WrappedHttpHandler.php(125): Aws\S3\GetBucketLocationParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#8 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\WrappedHttpHandler.php(92): Aws\WrappedHttpHandler->parseResponse(Object(Aws\Command), Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), Array)
#9 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(204): Aws\WrappedHttpHandler->Aws{closure}(Object(GuzzleHttp\Psr7\Response))
#10 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#11 E:\app\test\testaws\vendor\guzzlehttp\promises\src\TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#12 E:\app\test\testaws\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php(158): GuzzleHttp\Promise\TaskQueue->run()
#13 E:\app\test\testaws\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php(183): GuzzleHttp\Handler\CurlMultiHandler->tick()
#14 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#15 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#16 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#17 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#18 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#19 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#20 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#21 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait()
#22 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\AwsClientTrait.php(86): Aws\AwsClient->execute(Object(Aws\Command))
#23 E:\app\test\testaws\index.php(31): Aws\AwsClient->__call('putObject', Array)
#24 {main}

Next Aws\Api\Parser\Exception\ParserException: Error parsing XML: String could not be parsed as XML in E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\PayloadParserTrait.php:49
Stack trace:
#0 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\RestXmlParser.php(39): Aws\Api\Parser\RestXmlParser->parseXml(Object(GuzzleHttp\Psr7\Stream), Object(GuzzleHttp\Psr7\Response))
#1 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\RestXmlParser.php(31): Aws\Api\Parser\RestXmlParser->parseMemberFromStream(Object(GuzzleHttp\Psr7\Stream), Object(Aws\Api\StructureShape), Object(GuzzleHttp\Psr7\Response))
#2 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\Api\Parser\AbstractRestParser.php(63): Aws\Api\Parser\RestXmlParser->payload(Object(GuzzleHttp\Psr7\Response), Object(Aws\Api\StructureShape), Array)
#3 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\RetryableMalformedResponseParser.php(37): Aws\Api\Parser\AbstractRestParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#4 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\AmbiguousSuccessParser.php(69): Aws\S3\RetryableMalformedResponseParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#5 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\GetBucketLocationParser.php(29): Aws\S3\AmbiguousSuccessParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#6 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\WrappedHttpHandler.php(125): Aws\S3\GetBucketLocationParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#7 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\WrappedHttpHandler.php(92): Aws\WrappedHttpHandler->parseResponse(Object(Aws\Command), Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), Array)
#8 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(204): Aws\WrappedHttpHandler->Aws{closure}(Object(GuzzleHttp\Psr7\Response))
#9 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#10 E:\app\test\testaws\vendor\guzzlehttp\promises\src\TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#11 E:\app\test\testaws\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php(158): GuzzleHttp\Promise\TaskQueue->run()
#12 E:\app\test\testaws\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php(183): GuzzleHttp\Handler\CurlMultiHandler->tick()
#13 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#14 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#15 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#16 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#17 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#18 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#19 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#20 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait()
#21 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\AwsClientTrait.php(86): Aws\AwsClient->execute(Object(Aws\Command))
#22 E:\app\test\testaws\index.php(31): Aws\AwsClient->__call('putObject', Array)
#23 {main}

Next Aws\S3\Exception\S3Exception: Error parsing response for PutObject: AWS parsing error: Error parsing XML: String could not be parsed as XML in E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\RetryableMalformedResponseParser.php:39
Stack trace:
#0 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\AmbiguousSuccessParser.php(69): Aws\S3\RetryableMalformedResponseParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#1 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\S3\GetBucketLocationParser.php(29): Aws\S3\AmbiguousSuccessParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#2 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\WrappedHttpHandler.php(125): Aws\S3\GetBucketLocationParser->__invoke(Object(Aws\Command), Object(GuzzleHttp\Psr7\Response))
#3 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\WrappedHttpHandler.php(92): Aws\WrappedHttpHandler->parseResponse(Object(Aws\Command), Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), Array)
#4 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(204): Aws\WrappedHttpHandler->Aws{closure}(Object(GuzzleHttp\Psr7\Response))
#5 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#6 E:\app\test\testaws\vendor\guzzlehttp\promises\src\TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}()
#7 E:\app\test\testaws\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php(158): GuzzleHttp\Promise\TaskQueue->run()
#8 E:\app\test\testaws\vendor\guzzlehttp\guzzle\src\Handler\CurlMultiHandler.php(183): GuzzleHttp\Handler\CurlMultiHandler->tick()
#9 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(248): GuzzleHttp\Handler\CurlMultiHandler->execute(true)
#10 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#11 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#12 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#13 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#14 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#15 E:\app\test\testaws\vendor\guzzlehttp\promises\src\Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#16 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\AwsClientTrait.php(58): GuzzleHttp\Promise\Promise->wait()
#17 E:\app\test\testaws\vendor\aws\aws-sdk-php\src\AwsClientTrait.php(86): Aws\AwsClient->execute(Object(Aws\Command))
#18 E:\app\test\testaws\index.php(31): Aws\AwsClient->__call('putObject', Array)

Help me thanks

@StarrySkyDreamer StarrySkyDreamer added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Aug 16, 2021
@ajredniwja
Copy link
Contributor

Hi there, thanks for opening this issue can you please, can you set debug = true and paste the corresponding info between:

<- Leaving step attempt, name 'ApiCallAttemptMonitoringMiddleware'
------------------------------------------------------------------
until this line
<- Leaving step sign, name 's3.permanent_redirect'
--------------------------------------------------

@ajredniwja ajredniwja added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 18, 2021
@github-actions
Copy link

This issue has not recieved a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Aug 26, 2021
@anthonywebster
Copy link

Hi @Sunsetzzz , did you manage to solve? I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants