Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

javascript - How to GET data from outside an IFRAME GAS when a file is uploaded to Google Drive?

I recently saw this Github example using a Google Apps Script to upload a file to Google Drive: DRIVE EXAMPLE The Google Apps Script project works great, but I need to know if there is a way that when I put an IFRAME with the GAS Web App on a webpage and any user upload a file, the webpage can know the file was uploaded correctly receiving any kind of data from the GAS to use it for anything else?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

About Apps Script WebApps

  • This is a combination of a server-side code.gs file and a client-side html file
  • Communication between the parts is possible with scriptlets or google.script.run
  • The WebApp can either be used as a webpage on its own, or be embedded within a iframe.
  • For easier communication between client and server-side, I recommend you to integrate both the file-uploading functionalities and the feedback about the sucessfully uploaded file within the html file of the WebApp.
  • For example, implement an SuccessHandler that appends text to a on successful upload
  • Based on sample from the documentation:
<html>
  <head>
    <base target="_top">
    <script>
      function onSuccess() {
        var div = document.getElementById('output');
        div.innerHTML = 'The file upload was successful';
      }

      google.script.run.withSuccessHandler(onSuccess)
          .uploadToDrive(data);
    </script>
  </head>
  <body>
    <div id="output"></div>
  </body>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...