This is my scenario:
I receive a base64 image and my goal is to upload a jpg to S3 through the Flysystem library. I'm on Symfony 3.3.9.
Actually I reiceive this error when I try to use the writeStream method.
ftell(): supplied resource is not a valid stream resource in /opt/project/vendor/league/flysystem/src/Util.php line 250
Here's my code
$data = explode(',', $base64String, 2);
$relativePath = 'here/there.jpg';
$imageDecoded = base64_decode($data[1]);
$imageResource = imagecreatefromstring($imageDecoded);
$s3FileSystem->writeStream($relativePath, $imageResource,
['visibility' => AdapterInterface::VISIBILITY_PUBLIC,
'mimetype' => 'image/jpeg',
]);
Reading the docs of ftell() it says
The file pointer must be valid, and must point to a file successfully opened by fopen or popen.
How can I avoid this error? Should I save before the image to a file and after use fopen on it?
BTW I tried to save the image and it is correct, so no corrupt data.