Skip to content

List Bucket and List File #478

Description

@izzusan83

Hi all,
sorry but There isn't documentation about that.
is possible to have a bucket list and file list?

thanks

Activity

  1. izzusan83 commented on Apr 3, 2015

    @izzusan83
    Author

    ok i find the metod for to have bucket list and file list:

    // list all BUCKET
    storage.getBuckets(function(err, buckets, nextQuery) {
    
        for(var i = 0; i<buckets.length; i++ ){
        // The `metadata` property is populated for you with the metadata at the
        // time of fetching.
            console.log(buckets[i].metadata.id);
        }
    
     });
    
    // list all file
    bucket.getFiles(function(err, files, nextQuery) {
    
    
        // The `metadata` property is populated for you with the metadata at the
        // time of fetching.
    
        for(var i = 0; i<files.length; i++ ){
        // The `metadata` property is populated for you with the metadata at the
        // time of fetching.
            console.log(files[i].metadata.name);
        }
    
    
    
        // However, in cases where you are concerned the metadata could have
        // changed, use the `getMetadata` method.
       //files[0].getMetadata(function(err, metadata) {});
    });

    but now i have another question...

    is possible to create a folder in the bucket?

    thanks a lot

  2. leibale commented on Apr 4, 2015

    @leibale
    Contributor

    if you create file in path doesn't exist google will create the folders for you

  3. stephenplusplus commented on Apr 6, 2015

    @stephenplusplus
    Contributor

    As far as I know, that's the only way to create a folder outside of the Developer's Console UI. I think the solution of uploading a file and having a folder created in the process is fine, but feel free to correct me if you have a use case where that's not fine.

  4. izzusan83 commented on Apr 13, 2015

    @izzusan83
    Author

    yes, is true...

                            function(err,httpResponse,body){ 
    
                                var responseJson = JSON.parse(body);
    
                                if(responseJson.success){
    
                                    callToFunctionInModule("Start Upload in GoogleStorage", cb);
    
                                    var image = bucket.file('ddsImage.dds');
    
                                    fs.createReadStream(__dirname + '../../temp/ddsConversion/' + folderName + '/ddsImage.dds')
                                        .pipe(image.createWriteStream())
                                        .on('error', function(err) {
                                            console.log(err);
                                        })
                                        .on('complete', function() {
    
    
                                            }
    
                                            console.log('The file upload is complete.');
                                    });
                                }
                            });
    

    The folder temp doesn't exist. The first time google create the folder id doesn't exist.

    but if i need to remove the folder? I sow the method for remove file and buket but not for remove a folder,

    Thanks a lot

  5. added a commit that references this issue on Sep 27, 2022
  6. added a commit that references this issue on Nov 9, 2022
  7. 18 remaining items

  8. added a commit that references this issue on Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions