Reputation: 3734
I have this function that is supposed to return a format like this 2.3mb
function formatSize(bytes) {
var kb = 1024;
var ndx = Math.floor(Math.log(bytes) / Math.log(kb));
//var fileSizeTypes = ["bytes", "kb", "mb", "gb", "tb", "pb", "eb", "zb", "yb"];
var size = (bytes / kb / kb).toFixed(2);
var sizeInString = size.toString() + 'mb';
return sizeInString;
} // This is just a sample script. Paste your real code (javascript or HTML) here.
if ('this_is' == /an_example/) {
of_beautifier();
} else {
var a = b ? (c % d) : e[f];
}
When I try to put this to firestore it returns an error
Uncaught (in promise) Error: Function DocumentReference.set() called with invalid data. Unsupported field value: undefined (found in field size)
The rest is:
var fileSize = formatSize(fileN[0].size);
and
function putMessage(fileName, fileSize) {
db.collection("user").doc("document").collection('occur').add({
name: fileName,
size: fileSize,
})
.then(function(docRef) {
console.log("Document written");
})
.catch(function(error) {
console.error("Error putting Message:", error);
});
}
Why is firestore failing to save the field.
Upvotes: 1
Views: 20
Reputation: 3734
Found out the problem was wrong passing of arguments between functions making the variable to fail to get the value up top
Upvotes: 1