0
votes

I have been working on a code that will download a blob from the google drive using their API(V3). I want to get this working as I need to duplicate the file from google drive to firebase storage by using the fileUrl/ fileID.

I am able to export the pdf file after following a blog on medium

1

1 Answers

1
votes

To do this you need to:

  1. Get Drive file blob You can get the webContentLink and open it to download the file. If you were to curl it you would get the file contents.
  2. Create a reference to the file
// Create a root reference
var storageRef = firebase.storage().ref();

// Create a reference to 'mountains.jpg'
var mountainsRef = storageRef.child('mountains.jpg');
  1. Upload the Blob to the reference
 var file = ... // use the Blob you got on step 1
 ref.put(file).then(function(snapshot) {
   console.log('Uploaded a blob or file!');
 });

Hope this helps!