Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import dropbox
- from dropbox.exceptions import ApiError, AuthError
- import time
- import datetime
- import picamera
- import sys, os
- from time import sleep
- # Generate timestamp string generating name for photos
- def timestamp():
- tstring = datetime.datetime.now()
- print("Filename generated ...")
- return tstring.strftime("%Y%m%d_%H%M%S")
- #return tstring.strftime("image")
- Date = time.asctime( time.localtime(time.time()))
- class TransferData:
- def __init__(self, access_token):
- self.access_token = access_token
- print("Uploading....")
- def upload_file(self, file1_from, file1_to):
- """upload a file to Dropbox using API v2
- """
- dbx = dropbox.Dropbox(self.access_token)
- with open(file1_from, 'rb') as f:
- dbx.files_upload(f.read(), file1_to)
- def main():
- filename = timestamp()
- access_token = '8fEu-ziVNSAAAAAAAAAAPtmdg3mLC630heDTTuiX4kz_0Trv7EDFXUHiGzP0c9AB'
- transferData = TransferData(access_token)
- file1_from = '/home/pi/Downloads/imag1.jpg'
- file1_to = "/Test/%s"%filename + ".jpg" # The full path to upload the file to, including the file name
- # API v2
- transferData.upload_file(file1_from, file1_to)
- print("Uploading complete")
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement