-
Notifications
You must be signed in to change notification settings - Fork 370
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
Can't get buffer from File's download callback #676
Comments
If you're only interested in getting a buffer, then you can skip saving the file to your local file system if you omit the file.download({
// don't set destination here
}).then((data) => {
const contents = data[0]; // contents is the file as Buffer
}); Hope this answers your question. Please let us know if you are still running into issues. |
@jkwlui Thank you, it works. |
@jkwlui could you add this code snippet also to the docs? they are not in the examples. |
@jkwlui why 0 index is Buffer? Not intuitive at all. Could have been a |
Environment details
@google-cloud/storage
version: ^2.5.0I am trying to get file's buffer from google cloud storage, unfortunately there is nothing about buffer in documentation. However I found file api's download return buffer callback according to signatures of download function as follows.
callback supposed to return buffer as contents but it returns undefined and here is my code.
And here is my workaround which is not efficient.
How can I get a buffer from download function?
The text was updated successfully, but these errors were encountered: