Repository navigation
need example of how to store unindexed,binary data in datastore #971
Copy link
Copy link
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Activity
- addedtype: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.
on Nov 30, 2015 I think the answer is to use a Buffer which we'll then notice is a buffer, and set the value as the
blob_valuein the proto, which shouldn't be indexed... (code is here)So the example would look like:
var gcloud = require('gcloud')({ keyFilename: '/path/to/keyfile.json' }); var datastore = gcloud.datastore; var dataset = datastore.dataset({projectId: 'your-dataset-id'}); var yourBuffer = new Buffer([0x0000, 0x0001, 0x0002]); /* or you can set this to a file's contents: var yourBuffer = fs.readFileSync('/path/to/yourfile'); */ dataset.save({ key: dataset.key('YourKind'), data: { yourBlobProperty: yourBuffer }, function(err) { if (!err) { console.log('Just saved', key.path); } });
Going to mark this as closed, but feel free to re-open if you think this is wrong.
If you have an idea for how to improve the docs, feel free to open a PR. The examples for
dataset.savehave demos of the types we try to support:var key = dataset.key('Company'); dataset.save({ key: key, data: { name: 'DonutShack', // strings rating: gcloud.datastore.int(8), // ints worth: gcloud.datastore.double(123456.78), // doubles numDonutsServed: 45, // detect number type (int or double) founded: new Date('Tue May 12 2015 15:30:00 GMT-0400 (EDT)'), // dates isStartup: true, // booleans donutEmoji: new Buffer('\uD83C\uDF69'), // buffers keywords: [ 'donut', 'coffee', 'yum' ] // lists of objects } }, function(err) {});
- added a commit that references this issue
on Nov 11, 2022 - added a commit that references this issue
on Dec 12, 2024 - added a commit that references this issue
on Dec 17, 2024 - added a commit that references this issue
on Jul 23, 2025 - added a commit that references this issue
on Jan 28, 2026 - added a commit that references this issue
on Feb 17, 2026 - added a commit that references this issue
on Feb 24, 2026
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
I can't figure out how to store an entity in datastore that has this field... Any idea? Any example would be great
filecontents: {blobValue: filecontents, indexed: false},