How to get file name using fileupload field?

22 views
Skip to first unread message

Alexey Solonets

unread,
Oct 1, 2012, 7:23:51 AM10/1/12
to extdirec...@googlegroups.com
Hi again Gian Marco!
I've found that I can't get uploaded file name using ExtDirectHandler. I've looked into sources and found that you decided to select System.IO.Steam from Files collection inside the DoPost method. Why did you do this? Important information about file is lost.

I made a pull request with required modifications. Can you please review it?
Unfortunately changes are not backward compatible :( But project is young and I'm sure the sooner the better.

With best wishes.

Gian Marco Gherardi

unread,
Oct 3, 2012, 2:50:37 AM10/3/12
to extdirec...@googlegroups.com
Hi Alexey!

One of the design goal of ExtDirectHandler is supporting POCO class to be exposed as service. This mean that you don't have to use ExtDirectHandler or HTTP specific classes. For this reason, i choose to use the generic System.IO.Steam for passing files as parameter. 

To support what you are asking for and keep the option to have real POCO service classes, both Stream and HttpPostedFile should be supported.

Let me know what you think

Gian Marco Gherardi
http://gianmarco.gherardi.me

Alexey Solonets

unread,
Oct 4, 2012, 4:25:42 AM10/4/12
to extdirec...@googlegroups.com
Yeah, this approach looks more clear. I understand your idea.

I don't know how does the community use your project. In my architecture (Controllers -> Services -> Repositories) I use it in the Controllers layer only. So if previously I could use HttpPostedFile now I have to use HttpContext.Current.Request.Files. Not a big problem of course but also not clear.

What do you think about adding an option to ReflectionConfigurator something like this

new ReflectionConfigurator().UseHttpPostedFile(true)

or maybe 

new ReflectionConfigurator().RegisterType(concreteType).UseHttpPostedFile()

Gian Marco Gherardi

unread,
Oct 5, 2012, 12:11:17 PM10/5/12
to extdirec...@googlegroups.com
After some investigation, i end up with this implementation:


This way, both Stream and HttpPostedFile are supported seamlessly.

Let me know what you think

Gian Marco Gherardi
http://gianmarco.gherardi.me


Alexey Solonets

unread,
Oct 7, 2012, 8:20:58 AM10/7/12
to extdirec...@googlegroups.com
Looks great! You did this with very small number of changes. Cool :)

By the way I also noticed that I can't pass any different kind of parameters except for String and Stream when using FormHandler = true. Is this a bug or made intentionally?

Gian Marco Gherardi

unread,
Oct 7, 2012, 8:34:38 AM10/7/12
to extdirec...@googlegroups.com

On Sun, Oct 7, 2012 at 2:20 PM, Alexey Solonets <alexey....@gmail.com> wrote:
By the way I also noticed that I can't pass any different kind of parameters except for String and Stream when using FormHandler = true. Is this a bug or made intentionally?

It is intentional, because supporting type conversion from FormHandler require a specific converters implementation, i cannot simply rely on Json.NET like for normal cases. Given that Json.NET is also the way user can customize data conversion, also all the customization strategy has to be reimplemented.

Too much work for supporting just the file upload scenario (the only that justify the use of FormHandler AFAIK)

Alexey Solonets

unread,
Oct 9, 2012, 4:15:18 AM10/9/12
to extdirec...@googlegroups.com
Too much work for supporting just the file upload scenario (the only that justify the use of FormHandler AFAIK)
I agree. Anyway thanks for your help and quick reply! :)
Reply all
Reply to author
Forward
0 new messages