Something about FilesystemUploadStorageProvider.cs sourcecode!

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Something about FilesystemUploadStorageProvider.cs sourcecode!

Guest-833

Hi, Dean

    The code below is in the FilesystemUploadStorageProvider.cs file between line 60 and line 76

    foreach (string name in attrs.Keys)
                {
                    string val = attrs[name];
                    if (name == "tempDirectory")
                    {
                        if (HttpContext.Current != null)
                        {
                            val = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, val);
                        }
                        tempPath = val;
                    }
                    else
                    {
                        throw new System.Xml.XmlException("Unrecognized attribute: " + name);
                    }
                }

   I think the else block should remove from the source code, because if i have a subclass inherits from FilesystemUploadStorageProvider,

then i can't add any attributes to the add element in the web.config.

   I modify the source code like this:

  foreach (string name in attrs.Keys)
                {
                    string val = attrs[name];
                    if (name == "tempDirectory")
                    {
                        if (HttpContext.Current != null)
                        {
                            val = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, val);
                        }
                        tempPath = val;
                        break;
                    }
                }

PS: My english is not very well, i hope you can understand whay i say.

 

Reply | Threaded
Open this post in threaded view
|

Re: Something about FilesystemUploadStorageProvider.cs sourcecode!

Dean Brettle
Administrator
The problem with your change is that typos in attribute names will no longer be detected.  I recommend leaving the code as it was and overriding Initialize() in your class so that parses your attributes and only passes the tempDirectory attribute to base.Initialize().  If you want to support StorageConfig, you would need to do something similar in CreateUploadedFile().

--Dean
Reply | Threaded
Open this post in threaded view
|

Re: Something about FilesystemUploadStorageProvider.cs sourcecode!

Guest-833
OK, I got it, thx.