how to use my drive api downloaded file as an attachment on my app engine application
<p>I used the drive api to download a pdf file, and I want to use that file as an attachment using the app engine mail api (python). I have tried the following code below, the file downloaded and the email was sent but in the email there is no attachment at all. Please help me out</p>

<pre><code>class ManageGoogleDriveAPI(webapp2.RequestHandler):
def get(self):

    credentials = AppAssertionCredentials('https://www.googleapis.com/auth/drive')
    http_auth = credentials.authorize(Http())


    # Create a communication between my app and google api endpoint
    DRIVE = build('drive', 'v3', http=http_auth)

    file_id = '18mHxcum4n_-hxDBvmyEZaWTkirPuaWXptYAJG3PWGvU'

    request = DRIVE.files().export_media(fileId=file_id, mimeType='application/pdf')

    fh = io.BytesIO()
    downloader = MediaIoBaseDownload(fh, request)

    done = False
    while done is False:
        status, done = downloader.next_chunk()
        logging.info("Download %d%%." % int(status.progress() * 100))

    filename = 'hello.pdf'

    mail.send_mail(sender='app_name@appspot.gserviceaccount.com'.format(
        app_identity.get_application_id()),
                   to="johndoe@gmail.com",
                   subject=subject,
                   body=body,
                   attachments=[(filename, fh.read())])

    logging.info('COMPLETED!!')
    self.response.write('PROCESS COMPLETED!!, You can close this window now. Thank you!')
</code></pre>

<p>I finally figured what happened...</p>

<p>Instead of:</p>

<pre><code>attachments=[(filename, fh.read())])
</code></pre>

<p>Do this:</p>

<pre><code>attachments=[(filename, fh.getvalue())])
</code></pre>

python google-app-engine google-drive-sdk