Skip to content

Instantly share code, notes, and snippets.

@Sam-Lane
Created March 12, 2019 10:44
Show Gist options
  • Save Sam-Lane/d823a611fd9d77c64793e8dd43628691 to your computer and use it in GitHub Desktop.
Save Sam-Lane/d823a611fd9d77c64793e8dd43628691 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#source - https://stackoverflow.com/questions/23894221/upload-file-to-my-dropbox-from-python-script
import dropbox
class TransferData:
def __init__(self, access_token):
self.access_token = access_token
def upload_file(self, file_from, file_to):
"""upload a file to Dropbox using API v2
"""
dbx = dropbox.Dropbox(self.access_token)
with open(file_from, 'rb') as f:
dbx.files_upload(f.read(), file_to)
def main():
access_token = '******'
transferData = TransferData(access_token)
file_from = 'test.txt'
file_to = '/test_dropbox/test.txt' # The full path to upload the file to, including the file name
# API v2
transferData.upload_file(file_from, file_to)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment