'Batch a file, possibly flushing first, or perhaps upload it directly.
Args:
path: The name of the file.
payload: The contents of the file.
mime_type: The MIME Content-type of the file, or None.
If mime_type is None, application/octet-stream is substituted.'

def AddToBatch(self, path, payload, mime_type):

    if (not mime_type):
        mime_type = 'application/octet-stream'
    size = len(payload)
    if (size <= MAX_BATCH_FILE_SIZE):
        if ((len(self.batch) >= MAX_BATCH_COUNT) or ((self.batch_size + size) > MAX_BATCH_SIZE)):
            self.Flush()
        if self.batching:
            logging.info('Adding    %s    %s    (%s    bytes,    type=%s)    to    batch.', self.what, path, size, mime_type)
            self.batch.append((path, payload, mime_type))
            self.batch_size += (size + BATCH_OVERHEAD)
            return
    self.SendSingleFile(path, payload, mime_type)
