I have the contents of an SVG file in a variable in my code, and I would like to store it using the documented Automatic Streaming method of Laravel (basically using putFile or putFileAs methods) in a remote AWS S3 bucket.
SVG content (QR code) is dynamically generated by a package, so I do not have it previously stored in the filesystem (do not have a path):
$svg_contents = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" ...';
The problem is Laravel's putFile and putFileAs methods only accept Illuminate\Http\File or Illuminate\Http\UploadedFile instances as arguments. From Laravel docs:
// Automatically generate a unique ID for filename...
$path = Storage::putFile('photos', new File('/path/to/photo'));
// Manually specify a filename...
$path = Storage::putFileAs('photos', new File('/path/to/photo'), 'photo.jpg');
Any thoughts?
In other words, I am asking for a smart way to avoid storing it temporarily in local filesystem and then remotely store it in S3.
Thanks in advance.