Skip to main content

TUS py protocol implementation in FastAPI

Project description

FastAPI Tus

FastAPI Extension implementing the Tus.io server protocol

Prerequisites FastAPI

Installation

Installation from PyPi repository (recommended for latest stable release)

pip install tuspyserver

Usage

main.py

from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
from starlette.staticfiles import StaticFiles

from tusserver.tus import create_api_router

app = FastAPI()
app.add_middleware(
    CORSMiddleware,
    allow_origins=['*'],
    allow_methods=["*"],
    allow_headers=["*"],
)
app.mount("/static", StaticFiles(directory="static"), name="static")


def on_upload_complete(file_path: str):
    print('Upload complete')
    print(file_path)


app.include_router(
    create_api_router(
        files_dir='/tmp/different_dir', # OPTIONAL
        location='http://127.0.0.1:8000/files', # OPTIONAL
        max_size=128849018880, # OPTIONAL
        on_upload_complete=on_upload_complete # OPTIONAL
    ),
    prefix="/files"
)

This package has the ability to upload, download, delete (including a scheduler) files.

python setup.py sdist bdist_wheel

Any contribution is welcomed.

Buy Me A Coffee

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tuspyserver-2.0.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

tuspyserver-2.0.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file tuspyserver-2.0.0.tar.gz.

File metadata

  • Download URL: tuspyserver-2.0.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for tuspyserver-2.0.0.tar.gz
Algorithm Hash digest
SHA256 91d7a61d1de1b6841017021e3a7eb23eed0e0e0e33ca5db3072694bb30e2d7e4
MD5 3a294b0a517bd3e837562451f67072da
BLAKE2b-256 5c5ed45fc6b27f05d778e7a30dcc127eb2c69452b563d23fa2e752ff91aa1b6a

See more details on using hashes here.

File details

Details for the file tuspyserver-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: tuspyserver-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for tuspyserver-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b46272e8ead684fda8fe6530bf5614055a0dd611b70436e9e68c185f5aa03e9
MD5 6c49b4aab106b65c7a9e177da9013b19
BLAKE2b-256 9e57bee652aeff4b1ac4138f36a739715ab4a67cc9822ef8b90d5b270bdefdd2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page