Reputation: 199
I am trying to save an image of a canvas to my firebase database. But when I try to save it I get the following error.
Uncaught Error: Reference.set failed: First argument has a key path longer than 768 bytes (6829)
Is there any way I can make this string shorter so I could submit it. Below is the code I use to convert it to URL
function saveFunction(){
var canvas = document.getElementById("sheet");
var dataURL = canvas.toDataURL();
console.log(dataURL);
firebase.database().ref('Cords/' + dataURL).set({
Canvas:dataURL
});
}
Upvotes: 0
Views: 203
Reputation: 599491
A common way to shorten the string and keep it reasonably unique is to use its hash. You could use a simple numeric hash, an MD5 hash or one of the many other hashes.
Just keep in mind that the shorter the hash, the bigger the chances are of two strings mapping to the same hash value. So you'll want to use a hash that is reasonably long, to prevent such collisions.
Upvotes: 1