Reputation: 3
Supported data types I need to insert an image to Firestore as bytes manually but I don't understand how to do this because there is no bytes type. Is it possible?
Upvotes: 0
Views: 2122
Reputation: 138834
Supported data types I need to insert an image to Firestore as bytes manually.
If you need to store an image into a Firestore document, you need to write a byte array type field and not simply a byte. Since you didn't specify the programming language you are using, I'll answer it for Android, where you should use Blob's fromBytes() method to convert a byte array to a Blob object, then you can pass the Blob
object to set()
or update()
methods. Similarly, you can achieve the same thing in other programming languages too.
This is not highly recommended because there is a maximum document size of 1 MiB (1,048,576 bytes) limitation but as long as you stay within this limit for all the data the document combined, there won't be any problems. If you want to be safe, you can always check against the max size of a document using the FirestoreDocument-Android library.
Upvotes: 1