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

Accessing FORM in a HttpPost #19

Closed
shep1987 opened this issue Nov 26, 2018 · 6 comments
Closed

Accessing FORM in a HttpPost #19

shep1987 opened this issue Nov 26, 2018 · 6 comments

Comments

@shep1987
Copy link

I am looking to get hold of the form object from the HTTP request (reqest.Form.Files)to be able to get a file that is being sent to a function. We currently get this through the request in the function call and im unsure on how to map this to a Command. Help appreciated!
Thanks

Shaun

@JamesRandall
Copy link
Owner

Hmmm. That's a really good question. You can't at the moment but I'd be super interested in your thoughts on how this could work.

In an ideal world what would the command look like?

@shep1987
Copy link
Author

My original attempt was something like this:

public class PostFileForUploadCommand : ICommand<FileUploaded>
{
    public IFormCollection Form { get; set; }
}

You would then just have access to the form object like you do if you have the HttpRequest.

Thanks for the speedy reply!

@JamesRandall
Copy link
Owner

Thanks for that - makes sense. Bit snowed under with client work at the moment but I'll see if I can sneak something in along those lines as should be fairly simple.

@JamesRandall
Copy link
Owner

I managed to knock up a proof of concept of this on the train this morning - not tested yet but no real problems.

@shep1987
Copy link
Author

Sounds great! let me know if I can help in any way.

@JamesRandall
Copy link
Owner

This is now in v0.18.1 on NuGet now. It works just per your example: it will look for properties of type IFormCollection and map the HTTP request property onto them.

Just realised I forgot to document it in the guide but will do that shortly.

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

No branches or pull requests

2 participants