Reputation: 1424
I wrote a script to save email image attachments into google drive. But I receive way more than 250 per day (security camera snapshots).
The script works fine but I got the following message:
Service invoked too many times for one day: docslist create
After looping for threads, messages and attachments, I'm saving the attachments with:
file = subfolder.createFile(att[z]);
Is there another way to save the files that would let me go over the Apps Script limits?
Upvotes: 0
Views: 1171
Reputation: 1424
Not exactly an answer to the question, but an alternate way of solving the issue (to store a large quantity of files received by email):
I ended up using a Google Apps Script to upload the files to a separate server, by way of Class UrlFetchApp using a POST with the file as payload.
Upvotes: 0
Reputation: 46794
The answer is in the question : the quota limit for a consumer account is 250, there is no way to go over this except getting another type of account (see quotas in the link above).
What you could do is to store all the images in a single document , one for each day. Since the document can contain a lot of images (I don't even know if there is a limit...'*)
It might even be more convenient to use.
'* : this doc for example is a doc collecting pictures posted by SO user in a form I put online a few month ago and it's getting bigger every day (more than 200 page as of today, still growing ;-)
EDIT : following your comment:
you can simply append the image to the doc using a blob. Example below where I get the blob from my drive but any blob will do the job.
function importImage() {
var image = DriveApp.getFilesByType(MimeType.JPEG).next().getBlob()
var doc = DocumentApp.getActiveDocument()
var inlineI = doc.appendImage(image);
var width = inlineI.getWidth();
var newW = width;
var height = inlineI.getHeight();
var newH = height;
var ratio = width/height;
Logger.log('w='+width+'h='+height+' ratio='+ratio);
if(width>640){
newW = 640;
newH = parseInt(newW/ratio);
}
inlineI.setWidth(newW).setHeight(newH)
doc.appendParagraph('IMAGE size : '+width+' x '+height+' (eventually) resized to '+newW+' x '+newH+' for PREVIEW');
doc.appendHorizontalRule();
doc.saveAndClose();
}
Upvotes: 2