Crie um novo documento no Google Drive depois de processar o arquivo de texto enviado
Eu carreguei com sucesso um arquivo de texto para o Google Drive e escrevi um método que traduz com sucesso o texto para pig latin. Agora estou tentando criar um novo documento no Google Drive para gerar o texto traduzido. No entanto, sempre recebo a mensagem "Ocorreu um erro" e, quando verifico meu Drive, só tenho o texto original enviado.
Aqui está o meu código:
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;
}
O que devo fazer para criar o novo documento com sucesso a partir do texto enviado?