Comments (5)
@abdelhai you have more faith in the users than I do :) I've seen a few instances of incorrect file extensions the past.
I'd probably use a module like this one to make the conversion, if I was going to take that approach:
https://docs.python.org/3/library/mimetypes.html
The tool I'm working on should accept any file type really so I'll need to test it on quite a few different file types. Thanks for your help.
from deta-python.
This is the png I used for testing:
http://clipart-library.com/image_gallery/320477.png
from deta-python.
@timbusfield
You need to pass the media type with the response:
@app.get("/workorders/attachment/{attachmentStoredFilename}")
async def get_work_order_attachment(attachmentStoredFilename: str):
drive_streaming_body = deta_drive.download_file(attachmentStoredFilename)
return StreamingResponse(drive_streaming_body.iter_chunks(), media_type="image/png")
from deta-python.
Thanks very much, I'll make sure I capture the UploadFile.content_type when the file is uploaded so that I can pass it to the StreamingResponse as the media_type when it is downloaded later
from deta-python.
@timbusfield you could easily get the media type on the fly from the file's extension. Look at this simple example:
from deta-python.
Related Issues (20)
- TypeError: 'FetchResponse' object is not an iterator HOT 2
- The read operation timed out HOT 1
- AttributeError: module 'orjson' has no attribute 'JSONEncoder' in /opt/python/detalib/helpers.py class CustomJSONEncoder(json.JSONEncoder): HOT 5
- Base needs remove HOT 1
- send_email function in __init__.py HOT 3
- cron job App is not defined HOT 5
- Async Base TimeoutError HOT 1
- Deta is storing the wrong int HOT 1
- Questions: Does Deta supports npm? HOT 1
- Don't raise with the Exception class HOT 2
- Keyword argument expire_at for base.put() method not found (Python) HOT 3
- Wrong information in CONTRIBUTING.md HOT 1
- Deta Command Not Found HOT 1
- ✋ Use Discussions to get help: https://github.com/orgs/deta/discussions
- Empty keys not allowed HOT 1
- Add type hints strictly and provide
- Micro erroring due to detalib HOT 4
- The update() method seems to have a problem HOT 1
- ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2426) when trying to upload file to Deta drive HOT 2
- BIGINT trouble HOT 1
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 deta-python.