Utwórz nowy Doc na dysku Google po przetworzeniu przesłanego pliku tekstowego
Udało mi się załadować plik tekstowy na dysk Google i napisałem metodę, która z powodzeniem tłumaczy tekst na łaciński świnia. teraz próbuję utworzyć nowy dokument na Dysku Google, aby wydrukować przetłumaczony tekst. Zawsze jednak otrzymuję komunikat: „Wystąpił błąd” i gdy sprawdzam dysk, mam tylko oryginalny tekst przesłany.
Oto mój kod:
function doGet(e) {
var app = UiApp.createApplication().setTitle("Upload");
var formContent = app.createVerticalPanel();
formContent.add(app.createFileUpload().setName('thefile'));
formContent.add(app.createSubmitButton('submit'));
var form = app.createFormPanel();
form.add(formContent);
app.add(form);
return app;
}
function doPost(e) {
// data returned is a blob for FileUpload widget
var fileBlob = e.parameter.thefile;
var doc = DocsList.createFile(fileBlob);
var app = UiApp.getActiveApplication();
//Display a confirmation message
var label = app.createLabel('file uploaded successfully');
app.add(label);
return app;
var text = doc.getDataAsString();
Logger.log('I uploaded and my text is: ' + text);
MakeTranslationDoc(text);
}
function MakeTranslationDoc(passedText)
{
// Create a new Report
var newdoc = DocumentApp.create('Pig Latin Translation');
newdoc.appendParagraph(ParseText(passedText));
// Save and close the document
newdoc.saveAndClose();
}
function ParseText(myText)
{
...convert text to piglatin...
return results;
}
Co należy zrobić, aby pomyślnie utworzyć nowy dokument z przesłanego tekstu?