Closed eeroniemi closed 5 years ago
Hi!
I get the exact same error too:
Warning: fclose(): supplied resource is not a valid stream resource
$logger->info("Uplaoding local file", ['size' => $this->size, 'filename' => $this->filename]);
$fileSize = filesize($this->localfile);
if (!$fileSize)
throw new \DomainException("Couldn't read filesize! " . error_get_last());
$this->size = $fileSize;
$fh = fopen($this->localfile, "rb");
if (!is_resource($fh))
throw new \DomainException("Couldn't open file! " . error_get_last());
$success = $filesystem->writeStream($this->getRealPath(), $fh);
fclose($fh);
It might be tricky to solve, Guzzle6's Stream wrapper closes the stream on __destruct
,
This creates a few issues when using Flysystems ReplicateAdapter when the Stream is closed prematurely :/
doesn't this issue resides with the twistor/flysystem-stream-wrapper
package ?
Hi!
It's been a while since I looked at it, but I think this is the relevant file https://github.com/guzzle/psr7/blob/master/src/Stream.php#L78:
/**
* Closes the stream when the destructed
*/
public function __destruct()
{
$this->close();
}
Closed as this issue is not related to this package
I'm not sure if this is problem with FlysystemStreamWrapper or this library, but using the similar code with AWS S3 adapter works fine. If problem is with FlysystemStreamWrapper I can open separate issue there.
Problem is that when I register GoogleCloudStorageAdapter as stream wrapper and write to file using
file_put_contents
file is uploaded fine but I get PHP warnings.PHP version:
composer.json
test.php
Now when I run
php test.php
I would expect no errors, but what I actually get: