-
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
S3 putObject leaves file handles open #2335
Comments
Hi there, I ran into this issue as well. But the given workaround only works when the upload is not a multipart one. When the upload is a multipart one, there are multiple file handles created and they appear to never be closed. I'd happily make a PR but I am not sure where would be the best place to close these handles. My guess is that they should be closed somewhere after the |
hi there, this is off the top of my head and I would need some more time to look into this to say for sure, but if I recall correctly there's not an ideal place for the file handle to be closed. The file handle still needs to be open when the call to the service is made, so we may have to include a file to be closed in each call and close them individually after a successful response is returned from S3. |
Yeah the implementation makes it a bit tricky to find the correct place to close these handles. I wish you good luck 😃 In the meantime if anyone faces the same issue here’s a workaround to close the opened file handles $streams = get_resources('stream');
$uploadedFilePath = '/some/directory/my-file';
foreach ($streams as $stream) {
$meta = stream_get_meta_data($stream);
if (str_contains($meta['uri'] ?? '', $uploadedFilePath)) {
fclose($stream);
}
} |
We ran into the same problem today. I think the problem lies in the sourceFile middleware ( Using |
This is still happening like described in #81 |
I believe this is still happening. May be a different issue, but we're using PutObject with CommandPool (with thousands of files) and the resources are not being closed automatically. |
We are putting a file on S3 using putObject.
Once the transfer is completed, we are removing the file and try removing the directory. But when we are trying to remove the directory with rmdir, we get an error that the directory is not empty.
We did some searching and we found this bug report having the same behavior than us #81
We did the fix suggested by user mtdowling and it fixed our problem.
On the version 3.197.1 of aws-sdk-hp we had no problem. We updated to version 3.198.0 and our code stopped working.
PHP version: PHP 7.4.23 (cli) (built: Sep 3 2021 18:20:46) ( NTS )
This is how we patched it to get it working
`
$handle = fopen($sFilePath, 'r');
The text was updated successfully, but these errors were encountered: