diff --git a/lib/mbtiles.js b/lib/mbtiles.js index 66f99a1..054f052 100644 --- a/lib/mbtiles.js +++ b/lib/mbtiles.js @@ -549,7 +549,11 @@ MBTiles.prototype.putTile = function(z, x, y, data, callback) { // Tilelive may pass us a data.key. If not, generate an md5 // from the image buffer data. - var id = data.key || crypto.createHash('md5').update(data).digest('hex'); + var id; + if (data.key) + id = String(data.key); + else + id = crypto.createHash('md5').update(data).digest('hex'); if (!this._tileCache[id]) { // This corresponds to the images table. this._tileCache[id] = data;