N
N
newPsevdonim2021-08-18 00:25:03
Python
newPsevdonim, 2021-08-18 00:25:03

How to implement resumable google drive file upload?

There is a code that works with video files, the result needs to be uploaded to google drive using python. The documentation suggests a multi-party upload method, but the problem is that when uploading a file from 200mb, an error occurs. If I understand correctly this is due to connection interruption. The documentation also says about resumable loading, but I did not find anywhere how to implement it. Tell me how this can be done.

Here is the code where the error occurs for large files.

def upload_file(name_file, parents):
    file_metadata = {'name': name_file,
                     'parents': [parents]}
    media = MediaFileUpload('resalt_video.mp4', mimetype='video/mp4')
    file = service.files().create(body=file_metadata,
                                  media_body=media,
                                  fields='id').execute()
    print('File ID: %s' % file.get('id'))

service = make_conect()
upload_file('resalt_video.mp4', '1NH0qxXkAuX7L4ETd3cp0Un5cBDOLXYIg')

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question