Add prefixes to results from bucket.getFiles()#342
Conversation
|
Fixed |
regression/storage.js
Outdated
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? |
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. |
Update samples to match new Speech API
Update samples to match new Speech API

No description provided.