Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
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.
See documentation here: http://tus-py-client.readthedocs.io/en/latest/
pip install tuspy
Now you are ready to use the api.
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.
from tusclient.uploader import Uploader
my_uploader = Uploader('path/to/file.ext',
url='http://tusd.tusdemo.net/files/abcdef123456',
chunk_size=200)
If you want to work on tus-py-client internally, follow these few steps:
Setup virtual environment and install dependencies
python -m venv env/
source env/bin/activate
pip install -e .[test]
Running tests
pytest
Releasing a new version (see https://realpython.com/pypi-publish-python-package/)
# 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
MIT
FAQs
A Python client for the tus resumable upload protocol -> http://tus.io
We found that tuspy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.