SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

binary data is returning application/octet-stream for content-type of everything #270

Closed mwinter80 closed 6 years ago

mwinter80 commented 6 years ago

127.0.0.1:8080/db/bucket/id/binary/ is returning content-type of octet-stream even when 127.0.0.1:8080/db/bucket/id is returning the correct content type. I have confirmed this mongodb 3.6.3 and 3.2.12

This problem was not happening in restheart 3.0.0 I know that was a while ago, but I guess I am curious at least when this broke so I can use the most recent version where content type is returned correctly

thanks!

mkjsix commented 6 years ago

I can't reproduce this behavior with latest snapshots. RESTHeart automatically detects the binary type and returns it accordingly. AFAIK, the only case when this doesn't happen is when it can't recognize it. Internally it uses Apache Tika, which detects a very wide range of mime types.

If you still see this problem please provide instructions on how to reproduce it.

ujibang commented 6 years ago

I can't reproduce this as well.

Content-Type response header is returned accordingly (if tika can detect file type).

$ http -a a:a -f POST 127.0.0.1:8080/db/bucket.files file@what-is-an-api.pdf 
HTTP/1.1 201 Created
....
Location: http://127.0.0.1:8080/db/bucket.files/5aad5f6cd8c4490ce57b13db
.....

$ http -a a:a 127.0.0.1:8080/db/bucket.files/59e1d5c8e4b3b902f88b0dc4/binary
HTTP/1.1 200 OK
......
Content-Type: application/pdf
mwinter80 commented 6 years ago

it returns the data, but if you look at the content-type for (in your example): http -a a:a -f POST 127.0.0.1:8080/db/bucket.files file@what-is-an-api.pdf it will be application/pdf but: http -a a:a 127.0.0.1:8080/db/bucket.files/59e1d5c8e4b3b902f88b0dc4/binary returns application/octet-stream

ujibang commented 6 years ago

@mwinter80 in my example it correctly returns Content-Type: application/pdf

mwinter80 commented 6 years ago

oh. hmmm... in that case it isnt detecting my pdfs correctly. perhaps my pdfs are not being generated with the correct header.

ujibang commented 6 years ago

closing for now. @mwinter80 if you find more info, feel free to reopen