ring

aaron51 2022-10-31T20:15:00.954779Z

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`)

weavejester 2022-11-01T22:22:18.649399Z

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.

weavejester 2022-11-01T22:26:31.749569Z

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).

aaron51 2022-11-02T02:28:36.259289Z

Thank you @weavejester! 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.

aaron51 2022-11-04T02:05:39.634819Z

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

aaron51 2022-11-02T16:57:50.005549Z

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