Comments (6)
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.
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.
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.
From @stephenplusplus on April 14, 2017 16:1
Yes, everything else is state and internal data.
from nodejs-storage.
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.
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)
- Support Storage Control quickstart HOT 8
- Update mime dependency to ^4.0.0 HOT 10
- deps!: Remove form-data dependency in favor of Node 18 implementation
- FileMetadata type missing null on metadata for delete HOT 1
- The build failed HOT 2
- GetServiceAccountOptions missing projectIdentifier field
- Unable to generate signedUrl when using WIF under GKE HOT 11
- File.from picks up incorrect bucket name from passed URL HOT 3
- FR: Support HNS enablement in bucket metadata
- CreateBucketRequest type is misaligned with JSON API
- storage HMAC keys: should get metadata for an HMAC key failed HOT 2
- storage HMAC keys: should make the key INACTIVE failed HOT 2
- tests: move HMAC system tests to use emulator
- storage bucket hierarchical namespace: should create a bucket without hierarchical namespace enabled (explicit) failed HOT 1
- Missing interface's property HOT 4
- storage HMAC keys: should delete the key failed
- Signed URL prefix HOT 1
- preconditions not working HOT 2
- File.save sometimes returns a Promise that never rejects or resolves HOT 10
- storage HMAC keys: should delete the key failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-storage.