googleapis / googleapis/google-cloud-node

Misleading Sample/Documentation (samples/downloadFolderWithTransferManager.js)

Open
#7,347 0 comments 0 reactions 0 assignees View on GitHub
api: storage library: storage samples
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

### Please make sure you have searched for information in the following guides.

- [x] Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- [x] Check our Troubleshooting guide: https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/troubleshooting
- [x] Check our FAQ: https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/faq
- [x] Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- [x] Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- [x] Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples

### Documentation Request

# Fix misleading documentation in downloadFolderWithTransferManager.js sample

The documentation comment on line 31 of `samples/downloadFolderWithTransferManager.js` is misleading:

```javascript
// The ID of the GCS folder to download. The folder will be downloaded to the local path of the executing code.
```

However, the current implementation:
```javascript
await transferManager.downloadManyFiles(folderName);
```
Actually returns a Buffer[] array rather than downloading files to the local filesystem as the comment suggests.

To actually download files to the local filesystem as documented, the sample should include the passthroughOptions.destination parameter:

```
await transferManager.downloadManyFiles(folderName, {
passthroughOptions: {
destination: `${__dirname}/`
}
});
```
This is correctly noted on the [Transfer Manager Reference](https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/transfermanager)
which was how I was able to find out how I was supposed to write to the file system.

Image

Either update the code to include the destination option, or modify the comment to accurately reflect that the current implementation returns buffers rather than writing to disk.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.