#!/usr/bin/env python
# -*- coding: utf-8 -*-
import dropbox
import os
import sys

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:
            file_size = os.path.getsize(file_from)
            CHUNK_SIZE = 4 * 1024 * 1024

            if file_size <= CHUNK_SIZE:
                print(dbx.files_upload(f.read(), file_to, mode=dropbox.files.WriteMode.overwrite))
            else:
                upload_session_start_result = dbx.files_upload_session_start(f.read(CHUNK_SIZE))
                cursor = dropbox.files.UploadSessionCursor(session_id=upload_session_start_result.session_id,
                                                        offset=f.tell())
                commit = dropbox.files.CommitInfo(path=file_to, mode=dropbox.files.WriteMode.overwrite)

                while f.tell() < file_size:
                    if ((file_size - f.tell()) <= CHUNK_SIZE):
                        print(dbx.files_upload_session_finish(f.read(CHUNK_SIZE),
                                                        cursor,
                                                        commit))
                    else:
                        dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                                                        cursor.session_id,
                                                        cursor.offset)
                        cursor.offset = f.tell()

def main():
    access_token = os.getenv('DROPBOX_ACCESS_TOKEN')
    if access_token:
        transferData = TransferData(access_token)

        file_from = sys.argv[1]
        file_to = sys.argv[2]

        # API v2
        transferData.upload_file(file_from, file_to)
    else:
        print('Please set a valid DROPBOX_ACCESS_TOKEN in your environment')
        exit(1)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('Please provide input and output file')
        exit(1)

    main()

4b8ac4c78e20653f115ed9a67d1d5d81eb97359e
<mask token>


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:
            file_size = os.path.getsize(file_from)
            CHUNK_SIZE = 4 * 1024 * 1024
            if file_size <= CHUNK_SIZE:
                print(dbx.files_upload(f.read(), file_to, mode=dropbox.
                    files.WriteMode.overwrite))
            else:
                upload_session_start_result = dbx.files_upload_session_start(f
                    .read(CHUNK_SIZE))
                cursor = dropbox.files.UploadSessionCursor(session_id=
                    upload_session_start_result.session_id, offset=f.tell())
                commit = dropbox.files.CommitInfo(path=file_to, mode=
                    dropbox.files.WriteMode.overwrite)
                while f.tell() < file_size:
                    if file_size - f.tell() <= CHUNK_SIZE:
                        print(dbx.files_upload_session_finish(f.read(
                            CHUNK_SIZE), cursor, commit))
                    else:
                        dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                            cursor.session_id, cursor.offset)
                        cursor.offset = f.tell()


<mask token>

<mask token>


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:
            file_size = os.path.getsize(file_from)
            CHUNK_SIZE = 4 * 1024 * 1024
            if file_size <= CHUNK_SIZE:
                print(dbx.files_upload(f.read(), file_to, mode=dropbox.
                    files.WriteMode.overwrite))
            else:
                upload_session_start_result = dbx.files_upload_session_start(f
                    .read(CHUNK_SIZE))
                cursor = dropbox.files.UploadSessionCursor(session_id=
                    upload_session_start_result.session_id, offset=f.tell())
                commit = dropbox.files.CommitInfo(path=file_to, mode=
                    dropbox.files.WriteMode.overwrite)
                while f.tell() < file_size:
                    if file_size - f.tell() <= CHUNK_SIZE:
                        print(dbx.files_upload_session_finish(f.read(
                            CHUNK_SIZE), cursor, commit))
                    else:
                        dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                            cursor.session_id, cursor.offset)
                        cursor.offset = f.tell()


def main():
    access_token = os.getenv('DROPBOX_ACCESS_TOKEN')
    if access_token:
        transferData = TransferData(access_token)
        file_from = sys.argv[1]
        file_to = sys.argv[2]
        transferData.upload_file(file_from, file_to)
    else:
        print('Please set a valid DROPBOX_ACCESS_TOKEN in your environment')
        exit(1)


<mask token>

<mask token>


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:
            file_size = os.path.getsize(file_from)
            CHUNK_SIZE = 4 * 1024 * 1024
            if file_size <= CHUNK_SIZE:
                print(dbx.files_upload(f.read(), file_to, mode=dropbox.
                    files.WriteMode.overwrite))
            else:
                upload_session_start_result = dbx.files_upload_session_start(f
                    .read(CHUNK_SIZE))
                cursor = dropbox.files.UploadSessionCursor(session_id=
                    upload_session_start_result.session_id, offset=f.tell())
                commit = dropbox.files.CommitInfo(path=file_to, mode=
                    dropbox.files.WriteMode.overwrite)
                while f.tell() < file_size:
                    if file_size - f.tell() <= CHUNK_SIZE:
                        print(dbx.files_upload_session_finish(f.read(
                            CHUNK_SIZE), cursor, commit))
                    else:
                        dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                            cursor.session_id, cursor.offset)
                        cursor.offset = f.tell()


def main():
    access_token = os.getenv('DROPBOX_ACCESS_TOKEN')
    if access_token:
        transferData = TransferData(access_token)
        file_from = sys.argv[1]
        file_to = sys.argv[2]
        transferData.upload_file(file_from, file_to)
    else:
        print('Please set a valid DROPBOX_ACCESS_TOKEN in your environment')
        exit(1)


if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('Please provide input and output file')
        exit(1)
    main()

import dropbox
import os
import sys


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:
            file_size = os.path.getsize(file_from)
            CHUNK_SIZE = 4 * 1024 * 1024
            if file_size <= CHUNK_SIZE:
                print(dbx.files_upload(f.read(), file_to, mode=dropbox.
                    files.WriteMode.overwrite))
            else:
                upload_session_start_result = dbx.files_upload_session_start(f
                    .read(CHUNK_SIZE))
                cursor = dropbox.files.UploadSessionCursor(session_id=
                    upload_session_start_result.session_id, offset=f.tell())
                commit = dropbox.files.CommitInfo(path=file_to, mode=
                    dropbox.files.WriteMode.overwrite)
                while f.tell() < file_size:
                    if file_size - f.tell() <= CHUNK_SIZE:
                        print(dbx.files_upload_session_finish(f.read(
                            CHUNK_SIZE), cursor, commit))
                    else:
                        dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                            cursor.session_id, cursor.offset)
                        cursor.offset = f.tell()


def main():
    access_token = os.getenv('DROPBOX_ACCESS_TOKEN')
    if access_token:
        transferData = TransferData(access_token)
        file_from = sys.argv[1]
        file_to = sys.argv[2]
        transferData.upload_file(file_from, file_to)
    else:
        print('Please set a valid DROPBOX_ACCESS_TOKEN in your environment')
        exit(1)


if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('Please provide input and output file')
        exit(1)
    main()

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import dropbox
import os
import sys

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:
            file_size = os.path.getsize(file_from)
            CHUNK_SIZE = 4 * 1024 * 1024

            if file_size <= CHUNK_SIZE:
                print(dbx.files_upload(f.read(), file_to, mode=dropbox.files.WriteMode.overwrite))
            else:
                upload_session_start_result = dbx.files_upload_session_start(f.read(CHUNK_SIZE))
                cursor = dropbox.files.UploadSessionCursor(session_id=upload_session_start_result.session_id,
                                                        offset=f.tell())
                commit = dropbox.files.CommitInfo(path=file_to, mode=dropbox.files.WriteMode.overwrite)

                while f.tell() < file_size:
                    if ((file_size - f.tell()) <= CHUNK_SIZE):
                        print(dbx.files_upload_session_finish(f.read(CHUNK_SIZE),
                                                        cursor,
                                                        commit))
                    else:
                        dbx.files_upload_session_append(f.read(CHUNK_SIZE),
                                                        cursor.session_id,
                                                        cursor.offset)
                        cursor.offset = f.tell()

def main():
    access_token = os.getenv('DROPBOX_ACCESS_TOKEN')
    if access_token:
        transferData = TransferData(access_token)

        file_from = sys.argv[1]
        file_to = sys.argv[2]

        # API v2
        transferData.upload_file(file_from, file_to)
    else:
        print('Please set a valid DROPBOX_ACCESS_TOKEN in your environment')
        exit(1)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('Please provide input and output file')
        exit(1)

    main()
