Unstructured-IO / unstructured-api-tools

Apache License 2.0
28 stars 10 forks source link

fix: handle case where file.content_type is None #163

Closed awalker4 closed 1 year ago

awalker4 commented 1 year ago

I can't reproduce this with the Starlette test client, but the following snippet in a python shell is returning a 400 error from the hosted api.

import requests

filename="fake.doc"
with open(filename, "rb") as f:
    response = requests.post(
        "https://api.unstructured.io/general/v0/general",
        files={"files": (str(filename), f)},
    )

print(response.text)

When we don't specify the content type in requests, it's causing the FastAPI file.content_type to be None, at least on my machine.

awalker4 commented 1 year ago

The smoketest in unstructured-api uses requests so I managed to verify in the tests over there -> https://github.com/Unstructured-IO/unstructured-api/pull/80

Let me know if it would be helpful to still figure out a test on this end as well. (Doable if I can use requests to hit the test server but I'm not seeing an easy way in the internals of Starlette's TestClient)