I didn't think that was right, so I dug into it a bit more and realized Laravel was setting that stream_reads setting to false.
I dug a bit more and realized exactly what that TEMP resource actually did.
It's something from Guzzle, presumably done to stop you shooting your feet off: it writes the data to disk to stop you going OOM.
The behaviour I was seeing, despite using readStream(), was that for large files, I would get null instead of the resource.
If I examined the resource with stream_get_meta_data(), I saw it was a TEMP resource. The PHP docs don't really explain that much.
For a while, I assumed it was fine.
Then I ran it locally with a large file and my queue driver se to sync and noticed ... it took about 4 seconds to just read the file.
The default in Flysystem's driver is true:
https://github.com/thephpleague/flysystem-aws-s3-v3/blob/3.x/AwsS3V3Adapter.php#L127
this threw me off a bit, since I was looking at the driver on S3 and assumed the defaults.
And I was getting *a* resource, just not one that behaved in the way I assumed it would.
One more gotcha in #Laravel when working with S3.
Storage has a readStream() method, which returns a stream resource instead of trying to jam a heckin' 2GB zip into memory.
The method will always return a resource -- but out of the box, it won't be a resource to stream from S3.
For whatever reason, Laravel defaults the setting stream_reads to false:
Copying a big heckin' 2GB zip file around in S3 can potentially take a couple seconds.
I was hitting my Lambda's 10-second timeout as a result!
Got burned by the #Laravel Storage interface today.
I'm using an S3 filesystem. After a user uploaded a (potentially large) file to S3 and their form request is validated/saved, I was moving the file from a `tmp/` spot in S3 to a permanent spot.
This was done using ->move(), which I assumed would be an instantaneous rename operation.
Not so. S3 doesn't seem to *have* a move operation -- only copy -- and Flysystem uses that plus delete for "moving" objects.
Sir Michael has a podcast and it is everything we deserve
https://shows.acast.com/sturdywheelbarrows/episodes/a-small-horse-or-a-large-wheelbarrow
ended up getting this mostly done on Friday!
It needs some polish but there's time enough for that on Monday, probably.
SO INSTEAD I WILL WRITE SOME USER GUIDES BECAUSE I HATE FUN
Another loud noise and a whole horde of zombies are now coming at us.
We're retreating towards a cottage on the hilltop made of stone (so nobody can ever burn it down).
Ignoring the fact that it keeps emitting towering pillars of blinding light.
Beggars can't be choosers!
we've gotten a bit off track while slaying the zombies
and have determined that, canonically, Aluminum got its name because the first human to dig out of the ground just read the name off the tooltip for the item
Cleric: I cast Sacred Flame at the zombie
DM: this zombie crit its save, so it dodges like it's the fucking matrix
DM: Ayeron, your turn
Me: i'll throw some tentacles at the thriller zombie
Bard: I can see them all as if they are Robert Normalman. Do they look like Robert Normalman to me?
DM: no, none of them resemble him
Bard: how do I know? I've never seen Robert Normalman.
DM:
Bard: They do look normal.
DM: Some look Standard too.
Druid: ⁉️
Bard: are zombies wise?
DM: you can roll religion if you want to gauge the-
*Bard rolls nat 20*
DM: ok you know all their modifiers.
#Laravel, #PHP, #DnD (esp. #Eberron). Food & booze.
I will be using the #SpinachInquisition tag for threads about our campaigns.
Unfortunate admin of the yshi.org mastodon instance.