~busykoala/dropbox_upload

9cd18e4e196d44125c82ecc483baabc404d99f5d — Matthias Osswald 1 year, 6 months ago
Add initial implementation.
A  => .env.example +1 -0
@@ 1,1 @@
DROPBOX_ACCESS_TOKEN=xxx

A  => .gitignore +3 -0
@@ 1,3 @@
.env
.python-version
**/__pycache__/

A  => README.md +17 -0
@@ 1,17 @@
# ...

## Generate Dropbox Access Token

Set up an access token for your dropbox account with the permission
`files.content.write`.

https://dropbox.tech/developers/generate-an-access-token-for-your-own-account

Then put your token into the `.env` file (see `.env.example`).

## Run app

```
poetry install
poetry run python dropbox_upload/run.py
```

A  => dropbox_upload/__init__.py +6 -0
@@ 1,6 @@
import os
from dotenv import load_dotenv

load_dotenv()

DROPBOX_ACCESS_TOKEN = os.getenv("DROPBOX_ACCESS_TOKEN")

A  => dropbox_upload/run.py +13 -0
@@ 1,13 @@
from dropbox_upload.upload import Upload
import io


def main():
    dropbox_path = '/TestFolder/test.txt'
    f = io.BytesIO(b"some text data")
    uploader = Upload()
    uploader.upload_file(f, dropbox_path)


if __name__ == "__main__":
    main()

A  => dropbox_upload/upload.py +8 -0
@@ 1,8 @@
from dropbox_upload import DROPBOX_ACCESS_TOKEN
import dropbox


class Upload:
    def upload_file(self, bytesIO_data, upload_path):
        dbx = dropbox.Dropbox(DROPBOX_ACCESS_TOKEN)
        dbx.files_upload(bytesIO_data.read(), upload_path)

A  => poetry.lock +125 -0
@@ 1,125 @@
[[package]]
name = "certifi"
version = "2020.6.20"
description = "Python package for providing Mozilla's CA Bundle."
category = "main"
optional = false
python-versions = "*"

[[package]]
name = "chardet"
version = "3.0.4"
description = "Universal encoding detector for Python 2 and 3"
category = "main"
optional = false
python-versions = "*"

[[package]]
name = "dropbox"
version = "10.7.0"
description = "Official Dropbox API Client"
category = "main"
optional = false
python-versions = "*"

[package.dependencies]
requests = ">=2.16.2"
six = ">=1.12.0"

[[package]]
name = "idna"
version = "2.10"
description = "Internationalized Domain Names in Applications (IDNA)"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"

[[package]]
name = "python-dotenv"
version = "0.15.0"
description = "Add .env support to your django/flask apps in development and deployments"
category = "main"
optional = false
python-versions = "*"

[package.extras]
cli = ["click (>=5.0)"]

[[package]]
name = "requests"
version = "2.24.0"
description = "Python HTTP for Humans."
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"

[package.dependencies]
certifi = ">=2017.4.17"
chardet = ">=3.0.2,<4"
idna = ">=2.5,<3"
urllib3 = ">=1.21.1,<1.25.0 || >1.25.0,<1.25.1 || >1.25.1,<1.26"

[package.extras]
security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"]
socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]

[[package]]
name = "six"
version = "1.15.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"

[[package]]
name = "urllib3"
version = "1.25.11"
description = "HTTP library with thread-safe connection pooling, file post, and more."
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"

[package.extras]
brotli = ["brotlipy (>=0.6.0)"]
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]

[metadata]
lock-version = "1.1"
python-versions = "3.9"
content-hash = "65a01f7df74cdb7cf879c22795b1deb2b82148ec857a6627897db4d9eaeac5c7"

[metadata.files]
certifi = [
    {file = "certifi-2020.6.20-py2.py3-none-any.whl", hash = "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"},
    {file = "certifi-2020.6.20.tar.gz", hash = "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3"},
]
chardet = [
    {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"},
    {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"},
]
dropbox = [
    {file = "dropbox-10.7.0-py2-none-any.whl", hash = "sha256:c27ad74c0d7d6d4720161a63ecc8de7a2395a96d4c8221da9aac823f5a05ecb5"},
    {file = "dropbox-10.7.0-py3-none-any.whl", hash = "sha256:0f9fa451a930112f99ab1d3bb6782274f508b07695365c969aab3f0db4cd2dd8"},
    {file = "dropbox-10.7.0.tar.gz", hash = "sha256:08c1e0bbc16499e0138431e34777c35ea086734ff15ee5067b0df3424df2a9ec"},
]
idna = [
    {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"},
    {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"},
]
python-dotenv = [
    {file = "python-dotenv-0.15.0.tar.gz", hash = "sha256:587825ed60b1711daea4832cf37524dfd404325b7db5e25ebe88c495c9f807a0"},
    {file = "python_dotenv-0.15.0-py2.py3-none-any.whl", hash = "sha256:0c8d1b80d1a1e91717ea7d526178e3882732420b03f08afea0406db6402e220e"},
]
requests = [
    {file = "requests-2.24.0-py2.py3-none-any.whl", hash = "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"},
    {file = "requests-2.24.0.tar.gz", hash = "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b"},
]
six = [
    {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
    {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
]
urllib3 = [
    {file = "urllib3-1.25.11-py2.py3-none-any.whl", hash = "sha256:f5321fbe4bf3fefa0efd0bfe7fb14e90909eb62a48ccda331726b4319897dd5e"},
    {file = "urllib3-1.25.11.tar.gz", hash = "sha256:8d7eaa5a82a1cac232164990f04874c594c9453ec55eef02eab885aa02fc17a2"},
]

A  => pyproject.toml +17 -0
@@ 1,17 @@
[tool.poetry]
name = "dropbox_upload"
version = "0.1.0"
description = ""
authors = ["Matthias Osswald <m@osswald.li>"]
license = "GPLv3"

[tool.poetry.dependencies]
python = "3.9"
dropbox = "^10.7.0"
python-dotenv = "^0.15.0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"