1

I have variables which contain binary image data, mime type and file name. I want to upload the binary data to Google Drive. Are there any ways to upload this in python?

0

1 Answer 1

1

Upload is done in two parts first you upload the metadata, name , description .. then you upload a file stream containing the file data itself

file_metadata = {'name': 'photo.jpg'}
media = MediaFileUpload('files/photo.jpg', mimetype='image/jpeg')
file = drive_service.files().create(body=file_metadata,
                                    media_body=media,
                                    fields='id').execute()
print 'File ID: %s' % file.get('id')

Upload file data

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I want to upload the binary data directly, not save it to a file temporary. Can I do this?
you are limited to what the MediaFileUpload method supports

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.