0
votes

I'm trying to upload files to Storage.

All the examples that I can find are talking about local file path. (https://cloud.google.com/storage/docs/uploading-objects#storage-upload-object-code-sample)

I don't have access to local file path, I just have a blob object, or file object, or a base64 string of the image.

Here is my code:

const admin = require('firebase-admin');
admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    storageBucket: "xxx.appspot.com"
});
var bucket = admin.storage().bucket();
await bucket.upload(myBlobFile;

And I got this error message:

[ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object

Do you know if what I want is possible?

1

1 Answers

1
votes

I had the same issue and I was able to upload the file with the file object. You have to keep in mind that the object is an array so you must choose the index of the file you want to upload.