मैं बड़ी अपलोड अपलोड करने की अनुमति देने के लिए ड्राइव एपीपीएस ड्राइव ड्राइव एपीआई का उपयोग करने से मेरी अपलोड स्क्रिप्ट को कनवर्ट करने के लिए इस पोस्ट (How to Use Advanced Drive Service to Upload Files) में जवाब का पालन करने का प्रयास कर रहा था (मुझे सक्षम होने की आवश्यकता होगी 50 जीबी के आसपास फाइल अपलोड करने के लिए) लेकिन मुझे ज्यादा सफलता नहीं मिली है।बड़ी फ़ाइलों को अपलोड करने के लिए Google ड्राइव एपीआई का उपयोग
सब कुछ ठीक काम करता है जब मैं (मैं 20 एमबी के आसपास फाइलों के साथ की कोशिश की है) अपेक्षाकृत छोटे फ़ाइलों को अपलोड कर रहा हूँ, लेकिन जब मैं कोशिश करते हैं और (400 एमबी के आसपास) को एक बड़ी फ़ाइल अपलोड करें, कुछ भी नहीं होता।
मैं निम्नलिखित त्रुटियाँ मिलती है:
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
मैंने सोचा था कि डिस्क API मुझे किसी भी आकार फ़ाइल अपलोड करने की अनुमति चाहिए था? मैं क्या गलत कर रहा हूं? मैंने चेक किया और मैं ड्राइव एपीआई सक्षम करता हूं। कोई भी मदद बहुत ही सराहनीय होगी।
मेरे server.gs स्क्रिप्ट:
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();
}
}
मेरे form.html:
<!DOCTYPE html>
<!-- You can also include your own CSS styles -->
<link href='https://fonts.googleapis.com/css?family=Bitter' 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>
@noogui मुझे लगता है मैं साधारण अपलोड प्रकार उपयोग कर रहा हूँ संभालने हूँ। मुझे यकीन नहीं है कि मेरी स्क्रिप्ट में इसे कैसे बदला जाए। – LJB
इसे जांचें [रेपो] (https://github.com/googledrive/cors-upload- नमूना), यह आपको एक अंतर्दृष्टि दे सकता है। – noogui
मुझे पूरी तरह से यकीन नहीं है, लेकिन 'अपलोड टाइप' अप्रासंगिक है क्योंकि आप एडवांस ड्राइव सेवा का उपयोग कर रहे हैं, ड्राइव रीस्ट एपीआई नहीं। –