File: dropbox_upload.py

package info (click to toggle)
dioptas 0.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 163,396 kB
  • sloc: python: 28,770; makefile: 24; xml: 9; sh: 3
file content (17 lines) | stat: -rw-r--r-- 511 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python
import sys
import os

from dropbox import Dropbox

if len(sys.argv) != 3:
    print('Please provide file to upload and destination folder!')
    exit(-1)

if os.getenv('DROPBOX_TOKEN') == None:
    print('Please set the Dropbox api Access token as environment variable DROPBOX_TOKEN')
    exit(-1)

db = Dropbox(os.getenv('DROPBOX_TOKEN'))
db.files_upload(open(sys.argv[1], 'rb').read(), sys.argv[2])
print('{} successfully uploaded to dropbox folder {}'.format(sys.argv[1], sys.argv[2]))