javascript - Unable to use "save button (by google drive)" with data or blob source -


i save document google drive, document created in realtime on client side of web app, using google drive save button, doesn't work @ all.

this example saving static file i've taken there: https://developers.google.com/drive/v3/web/savetodrive , works

<script src="https://apis.google.com/js/platform.js" async defer></script> <div class="g-savetodrive"    data-src="//example.com/path/to/myfile.pdf"    data-filename="my statement.pdf"    data-sitename="my company name"> </div> 

and yes works,

but if try set data-src data or blob field, fail save or error

<div class="g-savetodrive"    data-src="data:image/png;base64,ivborw0kggoaaaansuheugaaaakaaaakcayaaabmbxs+aaaaaxnsr0iars4c6qaaaarnqu1baacxjwv8yquaaaajcehzcwaadsqaaa7eazurdhsaaaajsurbvchty/y/7ur/bgkacurjbsnc0f8au/ykqap+/vzjaabykgl8odpr0gaaaabjru5erkjggg=="    data-filename="my statement.pdf"    data-sitename="my company name"> </div> 

try here "live" version: https://jsbin.com/horopel/edit?html,js,console,output

blob same thing, not works, solution? better if reactjs solution, ideas welcome.

answer: save button not support blob source.

directly documentation have linked

requests files on different servers subject cross origin resource sharing (cors) restrictions.

1.the data-src url can served same domain, subdomain, , protocol domain button hosted.

be sure use matching protocols between page , data source.

to serve file when same page served both http , https, specify resource without protocol such data-src="//example.com/files/file.pdf", uses appropriate protocol based on how hosting page accessed.

as can see must file. cant send string value of file itself. have considered going though google drive api directly doing file upload of stream?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -