-
Notifications
You must be signed in to change notification settings - Fork 592
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
Add prefixes to results from bucket.getFiles() #342
Conversation
Fixed |
@@ -42,12 +42,12 @@ var files = { | |||
}; | |||
|
|||
function deleteFiles(bucket, callback) { | |||
bucket.getFiles(function(err, files) { | |||
bucket.getFiles(function (err, files) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@mchmielarski However it goes, could you squash the 'Fix *' commits at some point? |
Sorry for my novice question, but could you provide a practical use of prefixes, delimiters, and handling the result returned? |
|
||
``` sh | ||
$ npm run lint | ||
``` |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Re: use case for prefixes is as I understand it a simple filter for files e.g. file search |
I'm interested in terms of how one would use this library after merging this PR. I figured instead of guessing by the code, it would be best to let the suggester (PR-sender) help me understand :) |
with prefixes and delimiters you can use buckets as tree structure in easy way. I think that comment added to |
Would you mind demonstrating with a practical use? |
Would be nice with some practical use-cases in the docs. As a normal users I would have no idea what I should be using it for. |
Not considering the added complexity of Get folders in bucketfunction getFolders(bucket, callback) {
var query = { delimiter: '/' };
bucket.getFiles(query, function(err, files, nextQuery, prefixes) {
callback(err, prefixes);
});
} |
Thank you for that. I know the functionality is in the API, so it makes sense to expose it. But before I can figure out what a good API looks like for it, I need to see how it's meant to be used. Are there other use case anyone can think of? The complexity of prefixes + delimiters still seems quite expensive for such simple results -- assuming the results are "folder names". |
I'm only using it with delimiter = function getFoldersInFolder(bucket, folder, callback) {
var query = { delimiter: '/', prefix: folder };
bucket.getFiles(query, function(err, files, nextQuery, folders) {
callback(err, folders);
});
}
getFoldersInFolder(storage.bucket('myBucket'), 'my-photos/', cb); |
Using delimiter as something other than As for real-world applications and why-the-heck-would-anyone-do-that-anyway questions, it's beyond me. |
As a library that isn't about being a straight API bridge, maybe we can abstract what we're interested in with delimiters and prefixes, and expose them in a more usable way. So far, it sounds like getting files from a specified folder is the benefit. We should be able to make this API work to accomplish that: var query = {
folder: 'images'
};
myBucket.getFiles(query, function (err, files, nextQuery) {
// files = only files in a directory "images"
// delimiter defaults to "/" when `folder` option is given
}); And if we think this is important, we can go so far as to create a class for folders: myBucket.getFolders(function(err, folders, nextQuery) {})
myFolder.file("image1.jpg") |
Thought experiment: Is it possible to upload a file with a filename that contains the character |
I'm confused on this as well, and if I remember correctly, even the Dev Console UI was confused about it. However, as far as I know, |
Not on OS X. Creating a folder named |
Check it: https://github.com/evenemento/gcloud-node/tree/v2 |
@sindresorhus You're right, you can name the folder with a At least, this is the case that occurs when using the "Upload Folder" feature in the Google Cloud Developer Console. Might not have anything to worry about in this case then. |
@ryanseys Yeah, weird, you're right. |
I think supporting a Folder object / folder-specific methods is unnecessary. If we can trust |
Yes! 100% agree. |
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/13e8b547-7af0-436b-b85e-2c1942f8f36a/targets Source-Link: googleapis/synthtool@be74d3e
🤖 I have created a release \*beep\* \*boop\* --- ### [2.0.2](https://www.github.com/googleapis/nodejs-iot/compare/v2.0.1...v2.0.2) (2020-06-04) ### Bug Fixes * **deps:** update dependency @google-cloud/pubsub to v2 ([#341](https://www.github.com/googleapis/nodejs-iot/issues/341)) ([81609b8](https://www.github.com/googleapis/nodejs-iot/commit/81609b84406077532f58af70028ccf675fa838f3)) * **deps:** update dependency googleapis to v52 ([#343](https://www.github.com/googleapis/nodejs-iot/issues/343)) ([d26347e](https://www.github.com/googleapis/nodejs-iot/commit/d26347e4b80ac6bff4270442dc9f8e24c7245316)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 474338479 Source-Link: googleapis/googleapis@d5d35e0 Source-Link: googleapis/googleapis-gen@efcd3f9 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWZjZDNmOTM5NjJhMTAzZjY4ZjAwM2UyYTFlZWNkZTZmYTIxNmEyNyJ9 fix: allow passing gax instance to client constructor PiperOrigin-RevId: 470911839 Source-Link: googleapis/googleapis@3527566 Source-Link: googleapis/googleapis-gen@f16a1d2 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjE2YTFkMjI0ZjAwYTYzMGVhNDNkNmE5YTFhMzFmNTY2ZjQ1Y2RlYSJ9 feat: accept google-gax instance as a parameter Please see the documentation of the client constructor for details. PiperOrigin-RevId: 470332808 Source-Link: googleapis/googleapis@d4a2367 Source-Link: googleapis/googleapis-gen@e97a1ac Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTk3YTFhYzIwNGVhZDRmZTczNDFmOTFlNzJkYjdjNmFjNjAxNjM0MSJ9
#342) * build(node): add feat in node post-processor to add client library version number in snippet metadata Co-authored-by: Benjamin E. Coe <bencoe@google.com> Source-Link: googleapis/synthtool@d337b88 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:d106724ad2a96daa1b8d88de101ba50bdb30b8df62ffa0aa2b451d93b4556641
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [linkinator](https://togithub.com/JustinBeckwith/linkinator) | [`^2.0.3` -> `^4.0.0`](https://renovatebot.com/diffs/npm/linkinator/2.16.2/4.0.0) | [![age](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/compatibility-slim/2.16.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/linkinator/4.0.0/confidence-slim/2.16.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>JustinBeckwith/linkinator</summary> ### [`v4.0.0`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v4.0.0) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v3.1.0...v4.0.0) ##### Features - create new release with notes ([#​508](https://togithub.com/JustinBeckwith/linkinator/issues/508)) ([2cab633](https://togithub.com/JustinBeckwith/linkinator/commit/2cab633c9659eb10794a4bac06f8b0acdc3e2c0c)) ##### BREAKING CHANGES - The commits in [#​507](https://togithub.com/JustinBeckwith/linkinator/issues/507) and [#​506](https://togithub.com/JustinBeckwith/linkinator/issues/506) both had breaking changes. They included dropping support for Node.js 12.x and updating the CSV export to be streaming, and to use a new way of writing the CSV file. This is an empty to commit using the `BREAKING CHANGE` format in the commit message to ensure a release is triggered. ### [`v3.1.0`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v3.1.0) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v3.0.6...v3.1.0) ##### Features - allow --skip to be defined multiple times ([#​399](https://togithub.com/JustinBeckwith/linkinator/issues/399)) ([5ca5a46](https://togithub.com/JustinBeckwith/linkinator/commit/5ca5a461508e688de12e5ae6b4cfb6565f832ebf)) ### [`v3.0.6`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v3.0.6) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v3.0.5...v3.0.6) ##### Bug Fixes - **deps:** upgrade node-glob to v8 ([#​397](https://togithub.com/JustinBeckwith/linkinator/issues/397)) ([d334dc6](https://togithub.com/JustinBeckwith/linkinator/commit/d334dc6734cd7c2b73d7ed3dea0550a6c3072ad5)) ### [`v3.0.5`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v3.0.5) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v3.0.4...v3.0.5) ##### Bug Fixes - **deps:** upgrade to htmlparser2 v8.0.1 ([#​396](https://togithub.com/JustinBeckwith/linkinator/issues/396)) ([ba3b9a8](https://togithub.com/JustinBeckwith/linkinator/commit/ba3b9a8a9b19d39af6ed91790135e833b80c1eb6)) ### [`v3.0.4`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v3.0.4) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v3.0.3...v3.0.4) ##### Bug Fixes - **deps:** update dependency gaxios to v5 ([#​391](https://togithub.com/JustinBeckwith/linkinator/issues/391)) ([48af50e](https://togithub.com/JustinBeckwith/linkinator/commit/48af50e787731204aeb7eff41325c62291311e45)) ### [`v3.0.3`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v3.0.3) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v3.0.2...v3.0.3) ##### Bug Fixes - export getConfig from index ([#​371](https://togithub.com/JustinBeckwith/linkinator/issues/371)) ([0bc0355](https://togithub.com/JustinBeckwith/linkinator/commit/0bc0355c7e2ea457f247e6b52d1577b8c4ecb3a1)) ### [`v3.0.2`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v3.0.2) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v3.0.1...v3.0.2) ##### Bug Fixes - allow server root with trailing slash ([#​370](https://togithub.com/JustinBeckwith/linkinator/issues/370)) ([8adf6b0](https://togithub.com/JustinBeckwith/linkinator/commit/8adf6b025fda250e38461f1cdad40fe08c3b3b7c)) ### [`v3.0.1`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v3.0.1) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v3.0.0...v3.0.1) ##### Bug Fixes - decode path parts in local web server ([#​369](https://togithub.com/JustinBeckwith/linkinator/issues/369)) ([4696a0c](https://togithub.com/JustinBeckwith/linkinator/commit/4696a0c38c341b178ed815f47371fca955979feb)) ### [`v3.0.0`](https://togithub.com/JustinBeckwith/linkinator/releases/tag/v3.0.0) [Compare Source](https://togithub.com/JustinBeckwith/linkinator/compare/v2.16.2...v3.0.0) ##### Bug Fixes - **deps:** update dependency chalk to v5 ([#​362](https://togithub.com/JustinBeckwith/linkinator/issues/362)) ([4b17a8d](https://togithub.com/JustinBeckwith/linkinator/commit/4b17a8d87b649eaf813428f8ee6955e1d21dae4f)) - feat!: convert to es modules, drop node 10 ([#​359](https://togithub.com/JustinBeckwith/linkinator/issues/359)) ([efee299](https://togithub.com/JustinBeckwith/linkinator/commit/efee299ab8a805accef751eecf8538915a4e7783)), closes [#​359](https://togithub.com/JustinBeckwith/linkinator/issues/359) ##### BREAKING CHANGES - this module now requires node.js 12 and above, and has moved to es modules by default. </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 9am and before 3pm" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-document-ai).
…secrets.sh (#342) This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/e306327b-605f-4c07-9420-c106e40c47d5/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@e703494
fix: use google-gax v3.3.0 Source-Link: googleapis/synthtool@c73d112 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:b15a6f06cc06dcffa11e1bebdf1a74b6775a134aac24a0f86f51ddf728eb373e
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [webpack-cli](https://togithub.com/webpack/webpack-cli) | [`^3.3.10` -> `^4.0.0`](https://renovatebot.com/diffs/npm/webpack-cli/3.3.12/4.2.0) | [![age](https://badges.renovateapi.com/packages/npm/webpack-cli/4.2.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/webpack-cli/4.2.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/webpack-cli/4.2.0/compatibility-slim/3.3.12)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/webpack-cli/4.2.0/confidence-slim/3.3.12)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>webpack/webpack-cli</summary> ### [`v4.2.0`](https://togithub.com/webpack/webpack-cli/releases/webpack-cli@4.2.0) [Compare Source](https://togithub.com/webpack/webpack-cli/compare/webpack-cli@4.1.0...webpack-cli@4.2.0) ##### Bug Fixes - \--config-name behaviour for functional configs ([#​2006](https://togithub.com/webpack/webpack-cli/issues/2006)) ([29ecf8d](https://togithub.com/webpack/webpack-cli/commit/29ecf8dbcd1c5c7d75fc7fb1634107697832d952)) - assign cache value for default configs ([#​2013](https://togithub.com/webpack/webpack-cli/issues/2013)) ([d2e3c74](https://togithub.com/webpack/webpack-cli/commit/d2e3c74d32b0141c694259cf4f31e6c48b0f681d)) - callback deprecation ([#​1977](https://togithub.com/webpack/webpack-cli/issues/1977)) ([2cb0c0e](https://togithub.com/webpack/webpack-cli/commit/2cb0c0e383670949ce31231edbfda514f47c3dfc)) - handle core flags for webpack 4 ([#​2023](https://togithub.com/webpack/webpack-cli/issues/2023)) ([ea66a7e](https://togithub.com/webpack/webpack-cli/commit/ea66a7e3ec6eabcc439b96acb21e2a25be2e35e5)) - help and version functionality ([#​1972](https://togithub.com/webpack/webpack-cli/issues/1972)) ([e8010b3](https://togithub.com/webpack/webpack-cli/commit/e8010b3aac695971e542ad4d3584ce534da39b8f)) ##### Features - export utils from core for other packages ([#​2011](https://togithub.com/webpack/webpack-cli/issues/2011)) ([3004549](https://togithub.com/webpack/webpack-cli/commit/3004549c06b3fe00708d8e1eecf42419e0f72f66)) - progress supports string argument ([#​2000](https://togithub.com/webpack/webpack-cli/issues/2000)) ([f13346e](https://togithub.com/webpack/webpack-cli/commit/f13346e6acb46e982a5d20fa1d2ae56fc52523dc)) - suggest the closest match based on the Levenshtein distance algorithm ([#​2010](https://togithub.com/webpack/webpack-cli/issues/2010)) ([491a582](https://togithub.com/webpack/webpack-cli/commit/491a582620b64ed4acbccd04f687adc28a5e4cff)) ### [`v4.1.0`](https://togithub.com/webpack/webpack-cli/releases/webpack-cli@4.1.0) [Compare Source](https://togithub.com/webpack/webpack-cli/compare/webpack-cli@4.0.0...webpack-cli@4.1.0) ##### Bug Fixes - avoid unnecessary stringify ([#​1920](https://togithub.com/webpack/webpack-cli/issues/1920)) ([5ef1e7b](https://togithub.com/webpack/webpack-cli/commit/5ef1e7b074390406b76cb3e25dd90f045e1bd8a2)) - colored output ([#​1944](https://togithub.com/webpack/webpack-cli/issues/1944)) ([2bbbb14](https://togithub.com/webpack/webpack-cli/commit/2bbbb14ca9a404f2205c0f5a5515e73832ee6173)) - move init command to separate package ([#​1950](https://togithub.com/webpack/webpack-cli/issues/1950)) ([92ad475](https://togithub.com/webpack/webpack-cli/commit/92ad475d4b9606b5db7c31dd3666658301c95597)) - output stacktrace on errors ([#​1949](https://togithub.com/webpack/webpack-cli/issues/1949)) ([9ba9d6f](https://togithub.com/webpack/webpack-cli/commit/9ba9d6f460fb25fb79d52f4360239b8c4b471451)) - run CLI after webpack installation ([#​1951](https://togithub.com/webpack/webpack-cli/issues/1951)) ([564279e](https://togithub.com/webpack/webpack-cli/commit/564279e5b634a399647bcdb21449e5e6a7f0637e)) - support any config name ([#​1926](https://togithub.com/webpack/webpack-cli/issues/1926)) ([6f95b26](https://togithub.com/webpack/webpack-cli/commit/6f95b267bf6a3a3e71360f4de176a4ebbec3afa1)) - support array of functions and promises ([#​1946](https://togithub.com/webpack/webpack-cli/issues/1946)) ([2ace39b](https://togithub.com/webpack/webpack-cli/commit/2ace39b06117f558c0d8528cea9248253cbdf593)) - watch mode and options ([#​1931](https://togithub.com/webpack/webpack-cli/issues/1931)) ([258219a](https://togithub.com/webpack/webpack-cli/commit/258219a3bb606b228636e6373a3d20413c1f660e)) ##### Features - allow passing strings in env flag ([#​1939](https://togithub.com/webpack/webpack-cli/issues/1939)) ([cc081a2](https://togithub.com/webpack/webpack-cli/commit/cc081a256181e34137a89d2e9d37b04280b3f180)) ### [`v4.0.0`](https://togithub.com/webpack/webpack-cli/blob/master/CHANGELOG.md#​400-httpsgithubcomwebpackwebpack-clicomparewebpack-cli400-rc1webpack-cli400-2020-10-10) [Compare Source](https://togithub.com/webpack/webpack-cli/compare/v3.3.12...webpack-cli@4.0.0) ##### Bug Fixes - add compilation lifecycle in watch instance ([#​1903](https://togithub.com/webpack/webpack-cli/issues/1903)) ([02b6d21](https://togithub.com/webpack/webpack-cli/commit/02b6d21eaa20166a7ed37816de716b8fc22b756a)) - cleanup `package-utils` package ([#​1822](https://togithub.com/webpack/webpack-cli/issues/1822)) ([fd5b92b](https://togithub.com/webpack/webpack-cli/commit/fd5b92b3cd40361daec5bf4486e455a41f4c9738)) - cli-executer supplies args further up ([#​1904](https://togithub.com/webpack/webpack-cli/issues/1904)) ([097564a](https://togithub.com/webpack/webpack-cli/commit/097564a851b36b63e0a6bf88144997ef65aa057a)) - exit code for validation errors ([59f6303](https://togithub.com/webpack/webpack-cli/commit/59f63037fcbdbb8934b578b9adf5725bc4ae1235)) - exit process in case of schema errors ([71e89b4](https://togithub.com/webpack/webpack-cli/commit/71e89b4092d953ea587cc4f606451ab78cbcdb93)) ##### Features - assign config paths in build dependencies in cache config ([#​1900](https://togithub.com/webpack/webpack-cli/issues/1900)) ([7e90f11](https://togithub.com/webpack/webpack-cli/commit/7e90f110b119f36ef9def4f66cf4e17ccf1438cd)) </details> --- ### Renovate configuration :date: **Schedule**: "after 9am and before 3pm" (UTC). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/nodejs-security-center).
Update samples to match new Speech API
Update samples to match new Speech API
No description provided.