Got below error when try to upload a file without extension.
Unhandled exception: Missing MIME type for extension "" (KeyError)
from /usr/share/crystal/src/mime.cr:158:33 in 'from_extension'
from /usr/share/crystal/src/mime.cr:192:5 in 'from_filename'
from lib/crest/src/crest/forms/data_form.cr:39:7 in 'add_field'
from lib/crest/src/crest/forms/data_form.cr:20:11 in 'generate'
from lib/crest/src/crest/form.cr:9:7 in 'generate'
from lib/crest/src/crest/request.cr:303:14 in 'generate_form_data!'
from lib/crest/src/crest/request.cr:125:7 in 'initialize:params:headers:form:logging:handle_errors:params_encoder'
from lib/crest/src/crest/request.cr:159:5 in 'new:params:headers:form:logging:handle_errors:params_encoder'
I think it's reasonable to set a default mime type application/octet-stream when you can not get it from file extension.
Also, it would be nice to be able to upload IO::Memory instead of only File which is possible because HTTP::FormData::Builder#file accepts any instance of IO.
Got below error when try to upload a file without extension.
I think it's reasonable to set a default mime type
application/octet-stream
when you can not get it from file extension.Also, it would be nice to be able to upload
IO::Memory
instead of onlyFile
which is possible because HTTP::FormData::Builder#file accepts any instance ofIO
.@mamantoha