I try to create a web application (on google site) which uses google-apps-script to read data from standard .txt files. I succeed with the following code which uses FileUpload widget and wants me to chose the file.
function doGet() {
var app = UiApp.createApplication();
var form = app.createFormPanel().setId('form').setEncoding('multipart/form-data');
app.add(form);
var formContent = app.createGrid().resize(2,2);
form.add(formContent);
formContent.setWidget(0, 0, app.createLabel('File:'));
var fileUpload = app.createFileUpload().setName('thefile').setId('fileID');
formContent.setWidget(0, 1, fileUpload);
formContent.setWidget(1, 1, app.createSubmitButton('Submit'));
return app;
}
function doPost(e) {
var fileBlob = e.parameter.thefile;
var app = UiApp.getActiveApplication();
var metin = fileBlob.getDataAsString();
var dataAsByte = fileBlob.getBytes();
var stringArray = metin.split('\n');
return app;
}
But, what I need is to process several .txt files and collect the data. Hence this 'fileUpload widget' is not what I want. I want to give a list of file paths from my local disc, and process each file, of which the path is given by the list, successively.
So the method to fill the fileBlob using file paths would be the answer for me!
Thanks.