Comments (7)
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))
from fastapi-storages.
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.
@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.
@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.
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.
How can I go about using a callable? I wanted to upload something like /tmp/{user.id}/
from fastapi-storages.
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)
- Use Pathy for storage adapters HOT 1
- Support custom domain
- Support AWS_DEFAULT_ACL HOT 1
- Fix alembic migrations HOT 4
- Cannot open admin panel HOT 4
- Instead of overriding files, change file names. HOT 2
- Potential memory leak HOT 2
- SQLAlchemy filter by FileType
- Not able to edit fields in sql admin when using s3 filetype HOT 5
- High severity CVE in pillow package < 10.0.0
- FastAPI storages with alembic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastapi-storages.