Open richardhedges opened 4 years ago
I'm having trouble retrieving the contents of a file. I've created an array of files using the following:
$service = Storage::cloud()->getAdapter()->getService(); $files = Storage::cloud()->listContents('/');
I'm then looping that array and running the following:
$export = $service->files->export($file['path'], 'text/plain'); $contents = $export->getBody();
The above returns a Guzzle stream, so if I change the $contents variable to the following to retrieve the contents, I instead see an empty string:
$contents
$contents = $export->getBody()->getContents();
I have also tried using $file['basename'] instead of $file['path'] , but I see the same results.
$file['basename']
$file['path']
I'm having trouble retrieving the contents of a file. I've created an array of files using the following:
I'm then looping that array and running the following:
The above returns a Guzzle stream, so if I change the
$contents
variable to the following to retrieve the contents, I instead see an empty string:I have also tried using
$file['basename']
instead of$file['path']
, but I see the same results.Full code if it's needed
``` $service = Storage::cloud()->getAdapter()->getService(); $files = Storage::cloud()->listContents('/', false); foreach ($files as $file) { if ($file['name'] == 'test') { $export = $service->files->export($file['path'], 'text/plain'); $contents = $export->getBody()->getContents(); dd($contents); } } ```