example client application in c#

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

example client application in c#

Guest-364
Hi,

has anyone got a example client application in c#?

Thanks
Joolz (newbe)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Dean Brettle
Administrator
If you just want to stream the file to storage and don't care about the ProgressBar functionality, you should be able to use something like this code at csharpfriends.com.  You'll just need to add a unique NeatUpload_PostBackID query param to the URI you are uploading to as described in the relevant section of the NeatUpload manual.

--Dean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Guest-364
Hi, Thanks for your help

The code on the link you supplied says to upload using HTTP Post,
...
WebClient Client = new WebClient();
Client.UploadFile("http://www.csharpfriends.com/Members/index.aspx", "c:\wesiteFiles\newfile.aspx");
...

Client.UploadFile(string address, string filename)

Should it be in my case

...
WebClient Client = new WebClient();
Client.UploadFile("http://www.domain.com/neatupload/handleupload.aspx?NeatUpload_PostBackID=afa02a69...", "c:\myfile.zip");
...

how does neatupload know what file it's receiving? or do I have to add &inputfile=myfile.zip

regards

Julian
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Dean Brettle
Administrator
Sorry, I forgot to tell you that to use the WebClient class like this you will need to use the NeatUpload development snapshot (currently NeatUpload-trunk.425.zip).  When you use it, you can access the uploaded file via the UploadHttpModule.Files collection.  For more details, see the "Uploading without InputFile" section of the docs/Manual.html included with the snapshot.

--Dean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Guest-364
Hi,

Thanks for all your help and the new code, but could I also please ask you for an example of how to code the handleuploads.aspx file which will receive the files passed by
...
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

// Note create a unique ID for each upload
byte[] responseArray = myWebClient.UploadFile("http://www.domain.com/HTTPuploadproject/handleuploads.aspx?NeatUpload_PostBackID=afa02a6999e54541bb6873151d1dfbfc", "c:\\test.zip");
...

You say I should use UploadHttpModule.Files collection? but I am not certain who to do this, I have put a
...
<Upload:HiddenPostBackID ID="InputFile1" runat="server" />
...
On my web page but what next...

Thanks for all your help

Joolz (newbe)c#
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Dean Brettle
Administrator
The handleuploads.aspx page doesn't need to have any controls on it at all.  In it's Page_Load() method do:

UploadedFile file = UploadHttpModule.Files[0];
file.MoveTo("desired_path_on_server", MoveToOptions.Overwrite);

to save the file that you uploaded from the client to a particular filename.

--Dean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Guest-364
It has been a year since this thread has been posted.
It doesn't appear that the UploadHttpModule.Files[] collection has made it into the stable release yet. Any plans for that?

Should I decide to deploy a trunk release with this functionality, is 425 the best/safest bet? I see that you are up to 590 as far as trunk releases go. Is there a better option?

Should I choose a trunk release, are there any newer features that I should be concerned about or avoid if possible?

BTW, the control looks great. I am thinking of replacing an older, overpriced, and flaky, commercial assembly with this assembly, should I get it to work for my unusual needs (.NET client pushing RFC 1867 multipart/form-data mixed with files and data via HttpWebRequest over SSL). I appreciate the openness of the code, it will help me troubleshoot/patch any future problems much better.

Thanks
M Schneider
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Dean Brettle
Administrator
It has been a year since this thread has been posted.
It doesn't appear that the UploadHttpModule.Files[] collection has made it into the stable release yet. Any plans for that?

Plans? Yes.  Schedule? No.  :-)

For the next stable release, I really want to make the MultiFile control use Flash when available so that multiple files can be selected from the file dialog at the same time.  I just haven't found the time to do that yet.

Should I decide to deploy a trunk release with this functionality, is 425 the best/safest bet? I see that you are up to 590 as far as trunk releases go. Is there a better option?

I recommend going with the latest (currently 590) and reporting any bugs you find.  I do try to fix bugs in the trunk release promptly.

Should I choose a trunk release, are there any newer features that I should be concerned about or avoid if possible?

Strictly speaking, I can't guarantee that any new features in trunk will make it into the next stable release or will have the same API.  So the least risk is to only use the new features that you actually need.  That said, some features are more stable than others at this point.  I do expect the UploadHttpModule.Files[] feature to stick around.  The main thing that is still somewhat unstable is the MultiFile control.

--Dean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Guest-364
Thanks for your reply earlier.

I've made progress with some proof of concept code I've written. I was able to upload files using a pretty sparse form (to simulate what I would have if HttpWebRequest were the client), not using any of your ASP.NET server controls. The UploadHttpModule intercepted the upload, and I was able to move the file to disk storage. I appear to be able to upload files with and without the query parameter NeatUpload_PostBackID=[my value] in the action of the form element.

My next proof was to attempt to get progress working by returning an XML file (AJAX style) to the client at the same time it was uploading the file.

Using a page that looks something like the following:

public class ProgressXml : Brettle.Web.NeatUpload.ProgressPage
{
    private void Page_Load(object sender, System.EventArgs e)
    {
        Response.Write(@"<?xml version=""1.0"" encoding=""UTF-8""?><progress>");
        Response.Write("<percentdone>" + (int)(this.FractionComplete * 100).ToString() + "</percentdone>");
        //SNIP other progress elements here
        Response.Write("<status>" + this.Status.ToString() + "</status>");
        Response.Write("</progress>");
        Response.Flush();
    }

    //SNIP normal page initialization stuff here
}

This page is in the same directory as the upload handler.

I start an upload using the query parameter NeatUpload_PostBackID=[my value], then open a page to ProgressXml.aspx?NeatUpload_PostBackID=[my value]

The file uploads fine, but no matter how much I refresh it, I get a status of Unknown and all the other values stay at 0 as well.

The demo page when dropped in the same folder works fine. I'm using the 590 trunk build.

Any thoughts that might get me looking in the right direction?

Thanks
M Schneider
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Dean Brettle
Administrator
I start an upload using the query parameter NeatUpload_PostBackID=[my value]

Sounds good.

then open a page to ProgressXml.aspx?NeatUpload_PostBackID=[my value]

That should be:

ProgressXml.aspx?postBackID=[my value]

Does making that change fix it?

--Dean
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Guest-364
I gave this a whirl too, but had no success with it either:

<%@ Page language="c#" AutoEventWireup="false" Inherits="Brettle.Web.NeatUpload.ProgressPage" %>
<%@ Register TagPrefix="Upload" Namespace="Brettle.Web.NeatUpload" Assembly="Brettle.Web.NeatUpload" %>
<?xml version="1.0" encoding="UTF-8"?>
<progress>
    <percentdone><% = (FractionComplete * 100).ToString() %></percentdone>
    <status><% = Status.ToString() %></status>
</progress>


M Schneider
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

Guest-364

    ProgressXml.aspx?postBackID=[my value]

Yes, that works beautifully. Thank you so much, I knew it had to be something simple.

M Schneider
BGM
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: example client application in c#

BGM
This post was updated on .
In reply to this post by Dean Brettle
Ah, I know this is an old thread, but I am stuck in the same place.

I want to write a console program that initiates the uploading sequence on my web page.

I have followed this thread, and read the client sections in the docs, but am still stuck.

It seems that there is no "Files" available to the "UploadHttpModule" for my web page.
UploadedFile file = UploadHttpModule.Files[0];

Is it possible to just use a runline like this:
http://myserver/somesite/somepage/default.aspx?neatupload_postbackid=inputfile&inputfile="c:\test.txt"

Loading...