I am trying to upload a pdf file to google drive using the API. In the Google drive api documentation the only way to pass the file is by indicating the path on on your local pc with the use of fs.createReadStream
.
However in my front end, i'm getting the file as a pdf with the help of jspdf and autotable:
const doc = new jsPDF('portrait', 'px', 'a4') as jsPDFWIthPlugin
doc.autoTable({
head: [["Payment", "Payment Date", "Loan Amount", "Amortization Payment", "Balance"]],
body: this.scheduleArray
})
this.pdf = doc.output("blob")
this.data = doc.output('datauristring')
doc.save("table.pdf")
In the google drive api documentation it says I can upload to a google drive by specifying the local path for example fs.createReadStream('files/photo.jpg)
. But what if I want to upload a pdf that is for example in the form of a base64 encoded string like a data URI. How can files like that be uploaded using the google drive api?