Giter Site home page Giter Site logo

Comments (7)

pyostr avatar pyostr commented on May 22, 2024 1

U can override method get_name

def get_name(self, name: str) -> str:
        filename = secure_filename(Path(name).name)
        return str(Path(name).with_name(filename))

https://github.com/aminalaee/fastapi-storages/blob/615167aed103909271da82abff92d5c5cb47612f/fastapi_storages/s3.py#L63C12-L63C12

from fastapi-storages.

aminalaee avatar aminalaee commented on May 22, 2024 1

Yeah I think that makes sense, plus note that it can be a callable: https://docs.djangoproject.com/en/4.2/ref/models/fields/#django.db.models.FileField.upload_to

I think we can ignore upload_to="uploads/%Y/%m/%d/" for now, this can be achieved with the callable.

from fastapi-storages.

mmzeynalli avatar mmzeynalli commented on May 22, 2024

@aminalaee should we consider using MEDIA_ROOT just like Django, and add upload_to argument to FileType or ImageType? Or would it be good, to have storage argument (like now), plus upload_to?

from fastapi-storages.

aminalaee avatar aminalaee commented on May 22, 2024

@mmzeynalli What do you mean by storage arguments? Because I think we have storage class variables, if that's what you mean.

from fastapi-storages.

mmzeynalli avatar mmzeynalli commented on May 22, 2024

My bad, explanation was not clear.
I meant, when we create a FileType

class MyModel(Base):
    img  = mapped_column(FileType, upload_to="/path/to/file")

is what we want right? Which uses FileType.storage + upload_to path for file

from fastapi-storages.

regisin avatar regisin commented on May 22, 2024

How can I go about using a callable? I wanted to upload something like /tmp/{user.id}/

from fastapi-storages.

mmzeynalli avatar mmzeynalli commented on May 22, 2024

As of now, this feature is not implemented. Instead, you can change file name when you receive the file (for ex. API), giving it the needed path

from fastapi-storages.

Related Issues (12)

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.