Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add :field to :store option in ring.middleware.multipart-params #223

Open
meowcakes opened this issue Aug 21, 2015 · 2 comments
Open

Add :field to :store option in ring.middleware.multipart-params #223

meowcakes opened this issue Aug 21, 2015 · 2 comments

Comments

@meowcakes
Copy link

It would be nice to also have the field name passed to the :store function, like so:

(defn- parse-file-item
  "Parse a FileItemStream into a key-value pair. If the request is a file the
  supplied store function is used to save it."
  [^FileItemStream item store encoding]
  [(.getFieldName item)
   (if (.isFormField item)
     (Streams/asString (.openStream item) encoding)
     (store {:filename     (.getName item)
             :field        (.getFieldName item)
             :content-type (.getContentType item)
             :stream       (.openStream item)}))])

This way different logic can be applied depending on the field.

Thanks

@weavejester
Copy link
Member

To what end? Can you describe your use-case?

@meowcakes
Copy link
Author

So I have two (very large) files being uploaded with field names "foo" and "bar". I want to, while the upload is in progress, analyse the contents of the files while storing them somewhere. This way I can give the user instant feedback of the analysis after the files are uploaded, rather than subsequently analysing them from wherever they're stored after the upload is finished, which would incur a significant delay.

But, "foo" and "bar" need to be analysed in a different way, and the only way to figure out which analysis to perform is to have the field name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants