-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync.py
42 lines (28 loc) · 955 Bytes
/
sync.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import mimetypes
import httplib, urllib
from os.path import basename
def sync_files ():
pass
def upload_file(filename):
mime, encoding = mimetypes.guess_type(filename)
title = basename(filename)
size = os.path.getsize(filename)
url = 'https://www.googleapis.com/drive/v2/files?uploadType=resumable'
"""
media = MediaFileUpload(filename,
mimetype=mime,
resumable=True)
file = drive_service.files().insert(body={'title': title},
media_body=media,
fields='id').execute()
print 'File ID: %s' % file.get('id')
"""
headers = {
"X-Upload-Content-Type": mime,
"X-Upload-Content-Length": size,
"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"
}
if __name__ == '__main__':
upload_file('D:\Beta-Stuff\Insync\experiments\lame-syncer\sync-data\ABC.txt')