Fork me on GitHub
#ring
<
2022-10-31
>
aaron5120:10:00

I’m trying to get the content-type of a string part of a multipart request. ring.middleware.multipart-params seems to discard this for strings. Guess I will have to parse the original request body separately to get the content-type? (I hope the request :body can be read more than once…?) (`curl -F "paramName=paramValue;type=text/plain" url`)

weavejester22:11:18

I'm not sure what you mean by "seems to discard this for strings". The content type is passed to the store under the :content-type key.

weavejester22:11:31

Ah, re-reading it I think I know what you mean. Yes, currently non-stream values don't keep the content type. I'd accept a PR to provide an additional option to change that (disabled by default so as to maintain compatibility).

aaron5102:11:36

Thank you @U0BKWMG5B! What do you think about this… • Adding :content-type to the map on https://github.com/ring-clojure/ring/blob/8af4ab93190dfe5b4827c14b416a4cb92e18cdaf/ring-core/src/ring/middleware/multipart_params.clj#L82 • Skipping decode-string-values when (= :bytes (:encoding options)) So if encoding is :bytes, fields wouldn’t be decoded, instead returned as maps with byte arrays and the content-type. If this sounds OK I can send a PR.

aaron5116:11:50

On second thought, maybe I should just use org.apache.commons.fileupload directly and not use this middleware, since this may not be a common requirement

aaron5102:11:39

On third thought, org.synchronoss.cloud/nio-multipart-parser looks like just the thing