Is there a hint to actually upload image to S3 buc...
# help
r
Is there a hint to actually upload image to S3 bucket from a given url ? Trying with
$this->fileSystemService->writeStream($fileSystemStreamTransfer, $stream);
I guess I will have to download temporarily the image and do a kind of fopen to create the $stream argument ?
w
fopen supports opening remote urls if not deactivated for security reasons. So you do not need to download the image to a local file first but could open a stream for the remote url and pass this into
writeStream
👍 1
r
I am using this method , but still i get the error
Copy code
private function determineSource($url)
{
    // Use the contents of a file as the data source.
    if (is_string($url)) {
        $source= Psr7\Utils::tryFopen($url, 'r');
    }

//    Create a source stream.
//    $stream = Psr7\Utils::streamFor($source);
//    if (!$stream->isReadable()) {
//        throw new IAE('Source stream must be readable.');
//    }

    return $source;
}
Copy code
$stream = $this->determineSource($url);

// Upload file
$this->fileSystemService->writeStream($fileSystemStreamTransfer, $stream);
That is fixed, so just do not bother, thx anyway.
Do you have any hint how to get back from AWS the S3 url of the image that has just been uploaded ?
I am on it, no worries, all I need is bucket, region and prefixed url consts to create the url