Open VadimSafonov opened 9 months ago
Hi @VadimSafonov, sorry to hear about your issues. Can you please provide a minimal reproducible code so we can better investigate this?. For example, we would be able to see if happens by you providing a custom logfn, or if happens with the default logfn, which can be seen here. Our default implementation will use echo to display the value.
I look forward to your response.
Thanks!
Hi @yenfryherrerafeliz
I notice the following: 1 with default debug block config I got error, but file has been downloaded 2 without debug block config NO error, file has been downloaded
Hi @VadimSafonov, I tried to reproduce the reported issue with the code that you have provided but I was not able to. Would you be able to please create a test project from scratch and see if the behavior occurs there?, just to discard any outdated implementation.
I look forward to your response.
Thanks!
Hi @yenfryherrerafeliz I attach test project error is the same aws-sdk-test.tar.gz
At the latest SDK version problem still exists Even if specify debug => true, not array with config params
Hi @VadimSafonov, I will work on identifying what may be causing this issue this week and get back to you as soon as possible.
Thanks!
Hi @VadimSafonov ,
<?php
require 'vendor/autoload.php';
use Aws\S3\S3Client;
$s3Client = new S3Client([
'version' => 'latest',
'region' => 'us-east-1',
"debug" => [
'logfn' => function ($value) { echo $value; },
'stream_size' => 524288,
'scrub_auth' => true,
'http' => true,
'auth_strings' => [],
'auth_headers' => []
]
]);
$s3Client->registerStreamWrapper();
$localFilePath = "./text.txt";
$s3DestinationPath = "s3://foo-bucket-REDACTED/destination-file2.txt";
try {
if (copy($localFilePath, $s3DestinationPath)) {
echo "File was copied successfully to S3.\n";
} else {
echo "Failed to copy the file to S3.\n";
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// File was copied successfully to S3.
// no errors or warnings are shown.
I tried this both with the 'debug': true
, and with the debug an array options and neither one is causing the warning you have seen to be surfaced. Can you take a look at my code and see if I'm missing anything?
For reference Im using PHP 8.3.10 and "aws/aws-sdk-php": "3.318.0"
Can you try upgrading and see if this solves your issue?
Thanks, Ran~
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.
Ok. I'll try to run the code on php 8.3 I need some time
Hi @RanVaknin In your reproduce case you copy file from local to s3. This case works fine for me too But when copy file from s3 to local there is an error
Stack trace:
#0 /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(591): fprintf(Resource id #214, '<%s> [%s] ', 'GET https://tes...', 'PROGRESS')
#1 [internal function]: GuzzleHttp\Handler\StreamHandler::GuzzleHttp\Handler\{closure}(7, 0, NULL, 0, 15756, 932438)
#2 /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/vendor/guzzlehttp/psr7/src/Stream.php(234): fread(Resource id #219, 8192)
#3 /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(209): GuzzleHttp\Psr7\Stream->read(8192)
#4 [internal function]: Aws\S3\StreamWrapper->stream_read(8192)
#5 /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/test.php(26): copy('s3://test-unvso...', '/Users/vadimsaf...')
#6 {main}
thrown in /Users/vadimsafonov/Documents/GitHub/aws-sdk-test/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php on line 591
Darwin Kernel Version 23.5.0 php 8.3.10 aws sdk 3.320.8
Describe the bug
After fix #2855 new error if Aws\S3\S3Client created with debug with logfn
Uncaught Exception fprintf(): supplied resource is not a valid stream resource Stack trace: #0 /project/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php(514): fprintf(Resource id #637, '<%s> [%s] ', 'GET https://tes...', 'PROGRESS')
1 [internal function]: GuzzleHttp\Handler\StreamHandler->GuzzleHttp\Handler{closure}(7, 0, NULL, 0, 7671, 73602)
2
/project/vendor/guzzlehttp/psr7/src/Stream.php(228): fread(Resource id #642, 8192)
3
/project/vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(209): GuzzleHttp\Psr7\Stream->read(8192)
4 [internal function]: Aws\S3\StreamWrapper->stream_read(8192)
5
/project/vendor/symfony/filesystem/Filesystem.php(62): stream_copy_to_stream(Resource id #643, Resource id #645)
Expected Behavior
no error
Current Behavior
error
Reproduction Steps
copy file to s3
Possible Solution
No response
Additional Information/Context
No response
SDK version used
3.293.10
Environment details (Version of PHP (
php -v
)? OS name and version, etc.)PHP 8.2.13 (cli) (built: Nov 24 2023 13:15:01) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.13, Copyright (c) Zend Technologies with Zend OPcache v8.2.13, Copyright (c), by Zend Technologies