Skip to content

Firestore.Blob is not accepted on document set via the admin.firestore #536

@jimmykane

Description

@jimmykane

[READ] Step 1: Are you in the right place?

YES

[REQUIRED] Step 2: Describe your environment

  • Firebase SDK version: ^6.0.2
  • Firebase Component: Firestore
  • Component version: _____

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

Cannot save Blob to document

Relevant Code:

This is an issue with the Admin firestore. On the client side it works.

While trying to save a blob on my NODEJS Admin app I get

 Error: Value for argument "data" is not a valid Firestore document. Couldn't serialize object of type "Blob" (found in field data). Firestore doesn't support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).

However I do create that blob via the firestore blob class

I do create this like so:

// The import
import {firestore} from "firebase";

// The function 
export const parseQueue = functions.region('europe-west2').pubsub.schedule('every 1 minutes').onRun(async (context) => {

....code...

// The problem
writePromises.push(
          admin.firestore()
            .collection('users')
            .doc(userID)
            .collection('events')
            .doc(<string>event.getID())
            .collection('activities')
            .doc(<string>activity.getID())
            .collection('streams')
            .doc(stream.type)
            .set({
              type: stream.type,
              data: firestore.Blob.fromBase64String(new Buffer((Pako.gzip(JSON.stringify(stream.data), {to: 'string'})), 'binary').toString('base64')),
            }))

It seems that the admin firestore does not accept the Blob that is returned from firestore.Blob.fromBase64String or I am completly confused.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions