Code Monkey home page Code Monkey logo

tuspy-fast-api's Introduction

Hi there ๐Ÿ‘‹

๐ŸŒฑ I'm Edi Hasaj. ๐Ÿ”ญ I'm currently working on closed and open source projects.

It makes me so happy ๐Ÿ˜„ to see that my projects interest someone else and together we are building something useful.

โšกYou can use my Developer Tools if you are a developer.

tuspy-fast-api's People

Contributors

dependabot[bot] avatar edihasaj avatar jarey avatar max-l avatar outofnames avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tuspy-fast-api's Issues

New fast api and pydantic error

Hi,
I would ike to try this project for personal use, I used to use Tus-go with docker Image, the project works fine with the requirements.txt provided in the root folder of the repo.

But with the latest fast api version and pydantic v2 I think things have moved somewhere,

I have This error

{
    "detail": [
        {
            "type": "missing",
            "loc": [
                "query",
                "args"
            ],
            "msg": "Field required",
            "input": null,
            "url": "https://errors.pydantic.dev/2.5/v/missing"
        },
        {
            "type": "missing",
            "loc": [
                "query",
                "kwargs"
            ],
            "msg": "Field required",
            "input": null,
            "url": "https://errors.pydantic.dev/2.5/v/missing"
        }
    ]
}

and my requirements.txt is the following:

annotated-types==0.6.0
anyio==3.7.1
certifi==2023.11.17
click==8.1.7
dnspython==2.4.2
email-validator==2.1.0.post1
fastapi==0.104.1
h11==0.14.0
httpcore==1.0.2
httptools==0.6.1
httpx==0.25.1
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
orjson==3.9.10
pydantic==2.5.1
pydantic-extra-types==2.1.0
pydantic-settings==2.1.0
pydantic_core==2.14.3
python-dotenv==1.0.0
python-multipart==0.0.6
PyYAML==6.0.1
sniffio==1.3.0
starlette==0.27.0
tuspyserver==1.3.1
typing_extensions==4.8.0
ujson==5.8.0
uvicorn==0.24.0.post1
uvloop==0.19.0
watchfiles==0.21.0
websockets==12.0

PS: I would like to contribute to this project, but I dont know where the problem is in the code-source

Thank you very much

Server side event when a file upload is complete

It would be nice to get a server side callback when an upload is complete (last chunk received),
in this callback one could move the file from where it's at (currently hardcoded at /tmp/files/ae76a377ce0e44f3897d5542aca8067a)
and give it a proper name (for ex. the name on the client machine).

I guess the way to do this currently, would be to use the callback on the client side, and send a request to the server with
the file UUID, to move the file.

Also, is there a plan to unhardcode the following values (port = 8000, and FILES_DIR = '/tmp/files') ? :

https://github.com/edihasaj/tuspy-fast-api/blob/main/tusserver/tus.py#L14

https://github.com/edihasaj/tuspy-fast-api/blob/main/tusserver/tus.py#L130

Dependency injection in callback

Hi,

I'm trying to integrate this library into an already existing FastAPI application. This application we're trying to build with FastAPI best practices and using dependency injection (Depends()). We need to do some validation and post processing after a file upload, that requires us to call a lot of functions in the application used by other routes. What I've realised is, that it's not possible to call functions with dependencies from the callback, since the callback function itself is not depended upon. But depending on it makes it run prior to the route calling it, which is not what we want either. Have you given any thought to this, or have an idea on how to solve it?

Thanks!

Add authentication?

Thanks for providing this package! I was wondering if there's an easy way to add authentication to the various endpoints. For my use case, only users that are signed in are allowed to upload a file. So I need to check to make sure a valid user is signed in.

Similarly, for endpoints like download and delete, I want to make sure that the request is from the owner of the file, not just anyone who manages to get the UUID.

Is there a wrapper or a dependency hook or something that can be added to the different endpoints to allow us to implement custom authorization logic?

The only other option I see is to not use the create_api_router( ) function and instead manually copy/paste the routes it creates into a custom endpoint, and then alter the code for each endpoint. That's definitely doable but would be messy and would mean that any updates to the endpoint code in the future won't automatically be propagated, so some sort of wrapper or hook would be preferable if there's a way to do it.

Getting created 201 uploading is not working..

I am tring to upload the file using this package. i am getting 127.0.0.1:53810 - "POST /files/ HTTP/1.1" 201 Created upload is not started on this API. i am using tus-client-js in frontent.

TypeError: 'type' object is not subscriptable on Running an instance

I am running the test app and run the following issue on app start

class FileMetadata(BaseModel):
  File "/Users/elijahmwangi/Library/Python/3.8/lib/python/site-packages/tusserver/metadata.py", line 8, in FileMetadata
    metadata: dict[Any, str]
TypeError: 'type' object is not subscriptable

The major issue its running it with python3 i believe

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.