1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
Metadata-Version: 2.1
Name: tuspy
Version: 1.0.3
Summary: A Python client for the tus resumable upload protocol -> http://tus.io
Home-page: http://github.com/tus/tus-py-client/
Author: Ifedapo Olarewaju
Author-email: ifedapoolarewaju@gmail.com
License: MIT
Platform: any
Classifier: Programming Language :: Python
Classifier: Natural Language :: English
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: File Transfer Protocol (FTP)
Classifier: Topic :: Communications :: File Sharing
Requires-Python: >=3.5.3
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: requests>=2.18.4
Requires-Dist: tinydb>=3.5.0
Requires-Dist: aiohttp>=3.6.2
Provides-Extra: test
Requires-Dist: responses>=0.5.1; extra == "test"
Requires-Dist: aioresponses>=0.6.2; extra == "test"
Requires-Dist: coverage>=4.2; extra == "test"
Requires-Dist: pytest>=3.0.3; extra == "test"
Requires-Dist: pytest-cov<2.6,>=2.3.1; extra == "test"
Requires-Dist: parametrize>=0.1.1; extra == "test"
Provides-Extra: dev
Requires-Dist: tox>=2.3.1; extra == "dev"
Requires-Dist: sphinx-autobuild==2021.3.14; extra == "dev"
Requires-Dist: Sphinx==1.7.1; extra == "dev"
# tus-py-client [](https://github.com/tus/tus-py-client/actions/workflows/CI.yml)
> **tus** is a protocol based on HTTP for _resumable file uploads_. Resumable
> means that an upload can be interrupted at any moment and can be resumed without
> re-uploading the previous data again. An interruption may happen willingly, if
> the user wants to pause, or by accident in case of a network issue or server
> outage.
**tus-py-client** is a Python client for uploading files using the _tus_ protocol to any remote server supporting it.
## Documentation
See documentation here: http://tus-py-client.readthedocs.io/en/latest/
## Get started
```bash
pip install tuspy
```
Now you are ready to use the api.
```python
from tusclient import client
# Set Authorization headers if it is required
# by the tus server.
my_client = client.TusClient('http://tusd.tusdemo.net/files/',
headers={'Authorization': 'Basic xxyyZZAAbbCC='})
# Set more headers.
my_client.set_headers({'HEADER_NAME': 'HEADER_VALUE'})
uploader = my_client.uploader('path/to/file.ext', chunk_size=200)
# A file stream may also be passed in place of a file path.
fs = open('path/to/file.ext', mode=)
uploader = my_client.uploader(file_stream=fs, chunk_size=200)
# Upload a chunk i.e 200 bytes.
uploader.upload_chunk()
# Uploads the entire file.
# This uploads chunk by chunk.
uploader.upload()
# you could increase the chunk size to reduce the
# number of upload_chunk cycles.
uploader.chunk_size = 800
uploader.upload()
# Continue uploading chunks till total chunks uploaded reaches 1000 bytes.
uploader.upload(stop_at=1000)
```
If the upload url is known and the client headers are not required, uploaders can also be used standalone.
```python
from tusclient.uploader import Uploader
my_uploader = Uploader('path/to/file.ext',
url='http://tusd.tusdemo.net/files/abcdef123456',
chunk_size=200)
```
## Development
If you want to work on tus-py-client internally, follow these few steps:
1. Setup virtual environment and install dependencies
```bash
python -m venv env/
source env/bin/activate
pip install -e .[test]
```
2. Running tests
```bash
pytest
```
3. Releasing a new version (see https://realpython.com/pypi-publish-python-package/)
```bash
# Update version in tusclient/__init__.py
vim tusclient/__init__.py
# Update changelogs
vim CHANGELOG.md
pytest
# Commit and tag
git commit -m 'v1.2.3'
git tag v1.2.3
# Build and release
pip install build twine
python -m build
twine check dist/*
twine upload dist/*
# Then: make release on GitHub
```
## License
MIT
|