Skip to content

Commit

Permalink
Added automatic conversion of buffer to string in gridstore write
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Amor Kvalheim authored and Aaron Heckmann committed May 17, 2010
1 parent 70c44ac commit ef04cee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/mongodb/gridfs/gridstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var BinaryParser = require('../bson/binary_parser').BinaryParser,
OrderedHash = require('../bson/collections').OrderedHash,
Integer = require('../goog/math/integer').Integer,
Long = require('../goog/math/long').Long,
ObjectID = require('../bson/bson').ObjectID;
ObjectID = require('../bson/bson').ObjectID,
Buffer = require('buffer').Buffer;

var GridStore = exports.GridStore = function(db, filename, mode, options) {
this.db = db;
Expand Down Expand Up @@ -97,6 +98,7 @@ GridStore.prototype.write = function(string, close, callback) {
if(typeof close === "function") { callback = close; close = null; }
var self = this;
var finalClose = close == null ? false : close;
string = string instanceof Buffer ? string.toString() : string;

if(self.mode[0] != "w") {
callback(new Error(self.filename + " not opened for writing"), null);
Expand Down

0 comments on commit ef04cee

Please sign in to comment.