Giter Club home page Giter Club logo

Comments (6)

lukesneeringer avatar lukesneeringer commented on August 15, 2024

From @stephenplusplus on April 13, 2017 13:2

There is a lot of stuff on the object-- some is plumbing that enables our API to function. The only thing that's really meant for the user is the metadata property, which is the API's raw record of the resource.

In the context of getFiles(), the API response returns all of the metadata for each file. If we didn't include it on the object, it would require further API calls to download that information. To find the data you need, you should look into to the metadata object. In the case that you just want names, it's a simple map over the response:

bucket.getFiles(function(err, files) {
    if (!err) {
        var fileMetadataObjects = files.map(function(file) {
            return file.metadata
        })
        fs.writeFileSync("files.json", JSON.stringify(fileMetadataObjects))
    } else {
        console.error(err)
    }
})

And of course, if you just want the name, you can use file.metadata.name or any other properties that are relevant for your use.

from nodejs-storage.

lukesneeringer avatar lukesneeringer commented on August 15, 2024

From @stephenplusplus on April 13, 2017 13:12

Just to address the 271,000 lines of JSON, though, I'm not particularly thrilled about that. From a quick test, the output of one file for me was about 1,200 lines. I'll re-open so we can define those huge objects as non-enumerable, so they're hidden from the output.

from nodejs-storage.

lukesneeringer avatar lukesneeringer commented on August 15, 2024

From @adam-sandor on April 14, 2017 15:58

Ok so do I understand correctly that only the metadata is actually downloaded from the server?

from nodejs-storage.

lukesneeringer avatar lukesneeringer commented on August 15, 2024

From @stephenplusplus on April 14, 2017 16:1

Yes, everything else is state and internal data.

from nodejs-storage.

lukesneeringer avatar lukesneeringer commented on August 15, 2024

From @adam-sandor on April 14, 2017 16:21

Cool, then it was just me panicking :)
Still would be user friendlier to not have that metadata in the request I think.

from nodejs-storage.

stephenplusplus avatar stephenplusplus commented on August 15, 2024

This was originally reported in the context of Storage, but applies to all of the APIs. I re-opened in the core repo.

from nodejs-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.