久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 Google Drive API 上傳大文件

Using Google Drive API to upload large files(使用 Google Drive API 上傳大文件)
本文介紹了使用 Google Drive API 上傳大文件的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我試圖按照這篇文章中的答案(

上傳大文件時(shí),腳本會超時(shí),因此會顯示錯誤.

同樣,如果您有更高的上傳速度,那么使用腳本上傳 400MB 也是可能的.

I was trying to follow the answer in this post (How to Use Advanced Drive Service to Upload Files) to convert my upload script from using DriveApps to Drive API in order to allow large file uploads (I'll need to be able to upload files around 50 GB) but I haven't had much success.

Everything works fine when I'm uploading relatively small files (I've tried with files around 20 MB), but when I try and upload a larger file (around 400 MB), nothing happens.

I get the following errors:

POST 2601514732-mae_html_user_bin_i18n_mae_html_user.js:71 POST …3A1462412854269&fsid=4787eea0-1d3c-4fd8-b263-8bae40da182d&func=uploadFiles 413 ()

375182757-mae_html_driver_bin_i18n_mae_html_driver.js:113 GET …b263-8bae40da182d&token=AJuLMu2o9KnAOrSvzonQHNRGUelVpsakEg%3A1462412854269 500 ()

2601514732-mae_html_user_bin_i18n_mae_html_user.js:46 Uncaught NetworkError: Connection failure due to HTTP 500

I thought the Drive API was supposed to allow me to upload any size file? What am I doing wrong? I checked and I enable the Drive API. Any help is greatly appreciated.

My server.gs script:

 function doGet(e) {
   return template = HtmlService.createHtmlOutputFromFile('form.html');
   return template.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME);
 }

 function uploadFiles(form) {

   try {

     var dropbox = "File Transfer";
     var folder, folders = DriveApp.getFoldersByName(dropbox);

     if (folders.hasNext()) {
       folder = folders.next();
     } else {
       folder = DriveApp.createFolder(dropbox);
     }


     //Upload file and set various properties
     var mediaData = form.File1;    
     var timeStamp = new Date();

     var resource = {
       description: "File uploaded on: " + timeStamp
     };

     var file = Drive.Files.insert(resource, mediaData); // create file using Drive API
     var fileId = file.id;    
     var DriveAppFile = DriveApp.getFileById(fileId); // retrieve file in DriveApp scope. 

     DriveApp.removeFile(DriveAppFile); // remove new file from Users root My Drive
     folder.addFile(DriveAppFile); // puts file in selected folder

     return "Thank you for your submission."

   } catch (error) {
     return error.toString();
   }
 }

My form.html:

<!DOCTYPE html>

<!-- You can also include your own CSS styles -->
<link  rel='stylesheet' type='text/css'>

<div class="form-style-10">
<title>File Transfer </title>

<form id="myForm" name="myForm">
  <h1>  File Transfer </h1>
<p></p>

  <fieldset class="fields">
  <div class="section"> Files </div>
  <div class="inner-wrap">
    <label for="File1"> File 1 </label>
    <input type="file" name="File1" required />

  </div>
  </fieldset>

  <p>  </p>
  <p id="incompleteWarning" class="hideClass"> Please select a file to transfer. </p>
  <p id="bePatient" class="hideClass"> Please be patient while the file is being uploaded. Do not close or refresh the form. You will see a "transfer complete" message when the upload is finished.</p>

  <input id="submitbutton" type="button" value="Submit Application" />       
</form>

<div id="output" class="hideClass">
  <h1 id="TitleForm"> File Transfer </h1>
    <span id="ThankYou" >Transfer complete! If you need to transfer another file, you can use the same link again.
        </span>
</div>

</div>


<script type="text/javascript">

document.getElementById('submitbutton').addEventListener("click", validatefunction);

function validatefunction() {
   document.getElementById('submitbutton').val = 'Submitting...';
   //check for required fields
   var j = 0;
   var form = document.getElementById('myForm');
   var elem = form.elements;
   for (var i = 0; i < elem.length; i++){
     elem[i].className = "";
     if (elem[i].value === "" && elem[i].hasAttribute('required')){
       elem[i].className = "warning";
       j++;
    }
   }

   if (j === 0) {
       var btn = document.getElementById('submitbutton');
       btn.disabled = true;
       document.getElementById('incompleteWarning').style.display = 'none';
       document.getElementById('bePatient').style.display = 'inline';
           google.script.run.withSuccessHandler(fileUploaded).uploadFiles(this.parentNode);
    } else{
      document.getElementById('submitbutton').val = 'Submit Application';
      document.getElementById('incompleteWarning').style.display = 'inline';
      document.getElementById('incompleteWarning').style.color = 'red';
    }
};

</script>

<script>
    function fileUploaded(status) {
        document.getElementById('myForm').style.display = 'none';
        document.getElementById('output').style.display = 'inline';     
    }
</script>

<style>
 input { display:block; margin: 20px; }
</style>

解決方案

Apps Script services impose daily quotas and hard limitations on some features.

If you exceed a quota or limitation, your script will throw an exception and terminate execution.

While uploading a large file, the script time-outs and thus will show errors.

Again, if you have a higher upload speed then uploading 400MB might as well be possible using script.

這篇關(guān)于使用 Google Drive API 上傳大文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機(jī)器人提及發(fā)出該機(jī)器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復(fù)必須使用導(dǎo)入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務(wù)器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復(fù)“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務(wù)器時(shí)的歡迎消息)
主站蜘蛛池模板: 国产一区二区三区四区在线观看 | 日本午夜一区二区三区 | 91精品国产自产精品男人的天堂 | 国内久久 | www精品美女久久久tv | 欧美精品被 | 国产一级片91 | 国产高清在线精品 | 日韩一区二区三区在线视频 | 欧美午夜影院 | 99精品国自产在线观看 | 久久三区| 亚洲精品久久 | 久久久久亚洲国产| 91精品入口蜜桃 | 一级黄色片日本 | 国产在线a | 日本视频免费观看 | 激情国产在线 | 成人免费视频一区二区 | 日韩在线观看 | 国产精品国产精品国产专区不卡 | 国产美女自拍视频 | 亚洲精品区 | 台湾av在线 | 中文字幕免费在线观看 | 中文字幕久久精品 | 一区二区三区免费网站 | 国产在线观看网站 | 国产乱码精品一区二区三区忘忧草 | 成人在线视频网 | 羞羞视频网站 | www.中文字幕av | 伊人网综合 | 久久久久一区二区 | 狠狠爱免费视频 | 91大神新作在线观看 | 国产精品美女一区二区 | 免费视频中文字幕 | 久久精品网 | 欧美日韩国产一区二区 |