-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fprintf(): supplied resource is not a valid stream resource #2856
Comments
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! |
I notice the following: **There is reproduce code**<?php
require __DIR__ . "/vendor/autoload.php";
$s3 = new Aws\S3\S3Client([
"version" => "latest",
"region" => "us-east-1",
"retries" => 5,
"use_accelerate_endpoint" => true,
"credentials" => [
"key" => "my_key",
"secret" => "my_secret",
],
"debug" => [
'logfn' => function ($value) { echo $value; },
'stream_size' => 524288,
'scrub_auth' => true,
'http' => true,
'auth_strings' => [],
'auth_headers' => []
]
]);
$s3->registerStreamWrapper();
copy("path_to_file", __DIR__ . "/var/aws_download.pdf"); and i got error and log
|
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 |
At the latest SDK version problem still exists |
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 For reference Im using PHP 8.3.10 and Thanks, |
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 |
Hi @RanVaknin
Darwin Kernel Version 23.5.0 |
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
The text was updated successfully, but these errors were encountered: