How can i use this on the google apps script? i want to upload attachments from gmail. Also, i want to use the ocr function of google docs since all of the attatchments will be images.
function uploadFile() {
var image = UrlFetchApp.fetch('http://goo.gl/nd7zjB').getBlob();
var file = {
title: 'google_logo.png',
mimeType: 'image/png'
};
file = Drive.Files.insert(file, image);
Logger.log('ID: %s, File size (bytes): %s', file.id, file.fileSize);
}
Change your file varaible to Drive.Files.insert(file, image, {ocr: true});
Please note, OCR didn't work for me when I used the image you supplied. Test it out with this image and should work fine for you.
Here's a rough example of how to get an email attachment.
And some documentation on how to save files to Google Drive