SWFUpload and NeatUpload

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

SWFUpload and NeatUpload

Guest-382

I am building a sort of hybrid of your NeatUpload and SWFUpload (http://swfupload.mammon.se/index.php) - this will allow users to select more than one file at a time and pass that to the server - my question is is NeatUpload more dependent on the display side to split the file up or does the httphandler do more of that -

I have (briefly) looked at most of the code and cant seem to get a handle on what is happening in it and where

If I want to pass a large (360MB) file from SWFUpload to your http handler is there any real problems or do i need to wrap that with some extra code?

I realize you may know nothing of SWFUpload or want to learn anything about it but if you coudl kind of describe how your control and handler works together it might help me sort them out to work together

Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Dean Brettle
Administrator
SWFUpload looks really nice.  I've been looking for an open-source flash solution to integrate with NeatUpload.  I haven't actually tried it yet and probably won't be able to right away, but I *think* it should be pretty easy.  Try the following:

  1. Install the NeatUpload development snapshot (currently NeatUpload-trunk.439.zip).  You need to use the the development snapshot to access the uploaded file via Brettle.Web.NeatUpload.UploadHttpModule.Files.
  2. When you instantiate SWFUpload on your form, pass "HandleSWFUpload.aspx?NeatUpload_PostBackID=anything" for the upload_script parameter.
  3. Create a HandleSWFUpload.aspx page on your site.  It is the page that will be receiving uploads from SWFUpload.  It don't think it needs to have any controls on it.  It's Page_Load() method should be called once for each file that SWFUpload sends.
  4. In the Page_Load() method do:
    Brettle.Web.NeatUpload.UploadedFile file = Brettle.Web.NeatUpload.UploadHttpModule.Files["Filedata"];
    and then use the UploadedFile members to access the name, MIME type, and size of the file, and call the MoveTo() method to save the file in its permanent location.

I think that should do it.  Please let me know how it goes.

Thanks,

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

Re: SWFUpload and NeatUpload

Guest-382

Thats more info than I was hoping to get thanks !!!!!!!!!

I will most likely not be able to try it for a day or so as I am tyring to recover a failed hard drive but will report back about it as soon as I get it done

Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Guest-382

Dean - do I still need to add the http module to the web.config? - seems if I am calling a page that actually exists I dont need to then add it to the web.config but wanted to double check on that

I would need to build my own httpmodule if I was to have it handled  the same way yours is right?

Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Dean Brettle
Administrator
You do need to add NeatUpload's UploadHttpModule to the Web.config.  You do not need to write your own.

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

Re: SWFUpload and NeatUpload

Guest-382

hello,dean...

like what you say,i use the flash client to upload file and request http://url/?postbackid=randomid ,and i can see the tmep file has created when file uploading...

but i don't know how to save file?

"Brettle.Web.NeatUpload.UploadHttpModule.Files" can't found in the currently varsion...

how can i save/MoveTo the file...

help!

Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Dean Brettle
Administrator
UploadHttpModule.Files is only available in the development snapshot.  In NeatUpload-1.2.x, you need to put an InputFile control with an ID of "Filedata" on the page that SWFUpload uploads to.  Then, that InputFile control will contain the uploaded file on postback.

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

Re: SWFUpload and NeatUpload

Guest-382
I have resolved this issue...
 
I modify the method "Application_EndRequest" in the "UploadHttpModule.cs",like this:
 
            if (uploadContext != null)
            {
                #region modify by BB@6/4/08 22:11(beijing time) 
                if (uploadContext.Status == UploadStatus.Completed)
                {
                    foreach (string key in uploadContext.uploadedFiles.Keys)
                    {
                        UploadedFile file = uploadContext.uploadedFiles[key] as UploadedFile;
                        file.MoveTo(@"E:\Project\WebUpload\files\" +app.Request.QueryString[Config.Current.PostBackIDQueryParam].ToString() + DateTime.Now.ToString("hh-mm-ss-ffffff") + file.FileName, MoveToOptions.Overwrite);
                    }
                }
                #endregion
                uploadContext.RemoveUploadedFiles();
            }
 
howsoever, thank you very much...
 
now i can use the flash client(FileReference) to upload file,i think it has more friendly interface and no refresh progressbar...
 
if anybody want to try what i try,just add my msn(or mail to me): gd_gz_boy@hotmail.com (I live in China,so,choose the right time to contact me)
 
Dean,if there any question...just contact me...
Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Dean Brettle
Administrator
FYI, this line:

file.MoveTo(@"E:\Project\WebUpload\files\" +app.Request.QueryString[Config.Current.PostBackIDQueryParam].ToString() + DateTime.Now.ToString("hh-mm-ss-ffffff") + file.FileName, MoveToOptions.Overwrite);

is a potential security hole, because it allows an attacker to specify the path that the file will be moved to by changing the query string.  It would be more secure to just generate a GUID.

Also, I don't think you should need to modify UploadHttpModule.cs to achieve the desired effect.  You should be able to put similar code in the code behind for the page that receives the upload.

Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Guest-382

is a potential security hole, because it allows an attacker to specify the path that the file will be moved to by changing the query string.  It would be more secure to just generate a GUID.

it just a simple...

when i upload more then two file at the same time,i use the postbackid to differentiate which file was uploaded from which client...

and now i have a problem...

i use flash client to upload file,use http://xxx/xxx.aspx?postbackid=guid ,but i don't know which the request come from...and it become unsafe...

because when the flash run at debug mode(code in flash ide and press ctrl+enter),it completely without any restrictions to upload file...

now i want to get the where the request come from, Dean,do you know how to get it?

Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Dean Brettle
Administrator
Maintain a server-side mapping (in the application's cache or application state) from postbackID to the information you care about (e.g. user ID, files uploaded by that user, etc).  When rendering the page before postback, generate a unique postbackID and add an entry to the mapping with that index, filling in whatever info you know at that point (e.g. user ID).  When the postback (i.e. upload) occurs, save it under a unique name that has nothing to do with the query string, and use the postbackID to lookup the entry in the mapping and add the generated filename to that entry.
Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Guest-382

Dean,thank for your help...

I want to tell you the same,and now i setup a demo,and it work very well.
 
 
Tim
Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Tim
Hello. I too have dove into the world of using Flash for uploads due to the enormous GUI potential. I actually wrote a fire-fox like flash uploader thats as smooth as a desktop application progress bar.

However the support/tracing of flash uploads is lax. Often times the upload fails for no reason, stops, or returns "IO ERROR" with no explanation. The server was not restarted (im logging these events) and I can find no way to see what caused the upload to fail.

Based on what I read below (even though that was a couple versions ago) I believe I can easily implement the same thing using NeatUpload to handle the request.. But my question is why?

Will neat upload better handle the incoming file preventing the IO/Errors?
Will neat upload better handle session/application restarts?
Will neat upload better handle the incoming bit stream making it less prone to errors?
What is the major advantage to neatUpload vs HttpPostedFile? as HttpPostedFile supposedly streams direct to disk anyway..

I have had your product installed for years just never implemented because of the GUI issues..

many thanks
Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Dean Brettle
Administrator
The primary advantage of using NeatUpload over other Flash-based upload techniques is that it is able to provide a progress bar even if the user doesn't have Flash.

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

Re: SWFUpload and NeatUpload

Tim
So there are no benefits to using your HttpModules vs httpPostedFile + Flash?
Reply | Threaded
Open this post in threaded view
|

Re: SWFUpload and NeatUpload

Dean Brettle
Administrator
NeatUpload's UploadHttpModule primary job is to allow the server to monitor upload progress so that it can be displayed to the user.  Flash is capable of monitoring upload progress from the client side, so that capability of NeatUpload's UploadHttpModule isn't really needed if you are willing to require users to have Flash.

I should probably point out a few other potential advantages of NeatUpload:
  1. NeatUpload's UploadHttpModule can stream the upload through an custom UploadStorageProvider that can manipulate it as it is received and store it someplace other than the filesystem.  For exmpale, the SqlServerInputFile extension stores the uploaded file in SQLServer.
  2. NeatUpload's controls behave like the standard ASP.NET FileUpload or HtmlInputFile controls in that they provide access to the uploaded files as part of a form postback.  Flash uploads each file in a separate request, but NeatUpload does the work of keeping track of the individual files and providing access to them from the browser's form postback.
  3. If you have a web garden or web farm, the different requests from Flash could go to different application instances.  Assuming it is configured properly, NeatUpload shares the upload state across those instances so that it can be accessed from the instance handling the browser's postback.
  4. NeatUpload's client-side script ensures that an upload is not started if that page doesn't validate or the user clicks a button that is not suppose to start the upload.
  5. NeatUpload can show processing progress in the same progress display that displayed upload progress.
Hope that helps,

--Dean