Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty file contents #85

Open
richardhedges opened this issue Jun 4, 2020 · 0 comments
Open

Empty file contents #85

richardhedges opened this issue Jun 4, 2020 · 0 comments

Comments

@richardhedges
Copy link

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 = $export->getBody()->getContents();

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);

    }

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant