Showing posts with label upload. Show all posts
Showing posts with label upload. Show all posts

Wednesday, March 28, 2012

System.IO.Stream to resulting file.

I'm kicking myself as I've had this 'bug' before, and I cannot remember what it was that resolved it.

Essentially I'm re-writing my upload control, and its started exhibiting a weird 'corruption' thing.

Essentially I have this code:

Dim FileLenAs Integer = FileData.LengthDim FileDataByes(FileLen)As Byte' Initialize the stream.Dim ResourceStreamAs System.IO.Stream = FileData' Read the file into the byte array. ResourceStream.Read(FileDataByes, 0, FileLen)Dim SavingStreamAs System.IO.FileStream = _ System.IO.File.Create(Server.MapPath(Me.__VirtualPath & FileName))' Copy the byte array into a string.For iAs Integer = 0To FileLen - 1 SavingStream.WriteByte(FileDataByes(i).ToString())Next' Close the streams. ResourceStream.Close() SavingStream.Close()
FileData is a stream of the file, either from a server side file, or from a httppostedfile. The file appears to save ok, the size of the file is correct. And when checking the properties the byte count looks exactly the same.

But the file is quite obviously corrected, it wont open. I'm guessing the issue is to do with encoding. But I can't remember what I did to resolve it. I'm looking at my old framework and the code at this point is identical. Could it be something to do server settings changing the encoding of POSTS?

Pre-cheers.

Stevo.
Scratch that, its the literal 5 minutes after submitted a thread you realise your obvious mistake...

' Create the fragment.Dim FragmentAs String = _ Engine.Convert.ToHexString(FileData, 0, 2)
DOH! can't believe I forget to 'rewind' the stream after getting a fragment identifier...

Cheers anyways!

Saturday, March 24, 2012

System.Net.WebClient

Hey all... i have to login a page and upload a file to that page ( cant
access to the code ) , Patrice and Kevin told me i could do it with
System.Net.WebClient, i could, but with a test site here in my intranet,
that website ( HTTPS ) detects i m not using the login form.. and i cant log
in that app...how can an ASP page detects if i login with the site or using
webclient ?
tnx..
CHIN@dotnet.itags.org.KD
www.racingclub.com.arGenerally the web app will look for a cookie in the request that was
issued during a succesful login (assuming the web app is using forms
authentication).
Some tips on how to programatically login:
http://odetocode.com/Articles/162.aspx
Scott
http://www.OdeToCode.com/blogs/scott/
On Tue, 1 Feb 2005 09:22:58 -0300, "CHIN@.KD"
<racingnet_ac@.yahoo.com.ar> wrote:

>Hey all... i have to login a page and upload a file to that page ( cant
>access to the code ) , Patrice and Kevin told me i could do it with
>System.Net.WebClient, i could, but with a test site here in my intranet,
>that website ( HTTPS ) detects i m not using the login form.. and i cant lo
g
>in that app...how can an ASP page detects if i login with the site or using
>webclient ?
>tnx..

System.Net.WebClient

Hey all... i have to login a page and upload a file to that page ( cant
access to the code ) , Patrice and Kevin told me i could do it with
System.Net.WebClient, i could, but with a test site here in my intranet,
that website ( HTTPS ) detects i m not using the login form.. and i cant log
in that app...how can an ASP page detects if i login with the site or using
webclient ?

tnx..

--
CHIN@dotnet.itags.org.KD
www.racingclub.com.arGenerally the web app will look for a cookie in the request that was
issued during a succesful login (assuming the web app is using forms
authentication).

Some tips on how to programatically login:
http://odetocode.com/Articles/162.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 1 Feb 2005 09:22:58 -0300, "CHIN@.KD"
<racingnet_ac@.yahoo.com.ar> wrote:

>Hey all... i have to login a page and upload a file to that page ( cant
>access to the code ) , Patrice and Kevin told me i could do it with
>System.Net.WebClient, i could, but with a test site here in my intranet,
>that website ( HTTPS ) detects i m not using the login form.. and i cant log
>in that app...how can an ASP page detects if i login with the site or using
>webclient ?
>tnx..

System.Net.WebClient and UploadFile() Problem

I am using WebClient to upload a file to a remote server. The call I'm
making looks as follows:
webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Fed
eration.Zip",
@dotnet.itags.org."C:\Temp\Federation.Zip");
'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me exactly
what cannot be found. If I attempt to download this exact file from the same
exact URL using webClient.DownloadFile, it works fine!
Thanks for the help - Amos.You can not simply upload file on a server.
Something should wait for that file at the server end.
So url http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.
but to upload you must write an ASPX page that will accept file and save to
the folder on a server.
George.
"Amos Soma" <amos_j_soma@.yahoo.com> wrote in message
news:OqGt9oK7GHA.1248@.TK2MSFTNGP03.phx.gbl...
>I am using WebClient to upload a file to a remote server. The call I'm
>making looks as follows:
> webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/F
ederation.Zip",
> @."C:\Temp\Federation.Zip");
> 'Federation' is a virtual directory on the server I'm attempting to upload
> the file to. The URL is valid and the file I'm attempting to transfer
> exists. I keep getting 404 errors (not found). It's not clear to me
> exactly what cannot be found. If I attempt to download this exact file
> from the same exact URL using webClient.DownloadFile, it works fine!
> Thanks for the help - Amos.
>
Thus wrote George Ter-Saakov,

> You can not simply upload file on a server.
> Something should wait for that file at the server end.
> So url
> http://sdtpcal.someserver.com/Feder.../Federation.Zip to
> download file looks correct.
> but to upload you must write an ASPX page that will accept file and
> save to the folder on a server.
You only need a web application endpoint for POST requests. If the OP can
use PUT, the web server may support this without any special user code (IIS
does for sure).
Both WebClient.UploadFile(uri, "PUT", fileName) and WebClient.OpenWrite(uri,
"PUT") will do the trick.
Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

System.Net.WebClient and UploadFile() Problem

I am using WebClient to upload a file to a remote server. The call I'm
making looks as follows:

webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Federation.Zip",
@dotnet.itags.org."C:\Temp\Federation.Zip");

'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me exactly
what cannot be found. If I attempt to download this exact file from the same
exact URL using webClient.DownloadFile, it works fine!

Thanks for the help - Amos.You can not simply upload file on a server.
Something should wait for that file at the server end.

So url http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.

but to upload you must write an ASPX page that will accept file and save to
the folder on a server.

George.

"Amos Soma" <amos_j_soma@.yahoo.comwrote in message
news:OqGt9oK7GHA.1248@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>I am using WebClient to upload a file to a remote server. The call I'm
>making looks as follows:
>
webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Federation.Zip",
@."C:\Temp\Federation.Zip");
>
'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me
exactly what cannot be found. If I attempt to download this exact file
from the same exact URL using webClient.DownloadFile, it works fine!
>
Thanks for the help - Amos.
>
>


Thus wrote George Ter-Saakov,

Quote:

Originally Posted by

You can not simply upload file on a server.
Something should wait for that file at the server end.
So url
http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.
>
but to upload you must write an ASPX page that will accept file and
save to the folder on a server.


You only need a web application endpoint for POST requests. If the OP can
use PUT, the web server may support this without any special user code (IIS
does for sure).

Both WebClient.UploadFile(uri, "PUT", fileName) and WebClient.OpenWrite(uri,
"PUT") will do the trick.

Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

System.Net.WebException: The request was aborted: The request was canceled.

Hello everyone,

Can anyone help me solve this problem? I'm trying to upload files from a client side to the server side, it uploads fine for any small files under <20mb and fails any files >20mb. I have set in the server side web config for the Runtime executionTimeout="650" and the maximum size length is 100MB, it it still fails under 2 minutes from the time it starts upload to the time the request was aborted, the request was cancel. Can anyone tell me is this a timeout from the Client side or a Service side and how do I fix this timeout issue to get the upload files to the host without being timeout?

anyone?


Is the stack trace available?

I suspecting the web.config file doesn't even take effect.


minutem for replying, here is the trace log that fail to upload th large file, because the System.Net.WebException: The request was aborted: The request was canceled.

"12-04-2007 14:52:48: Uploading c:\test\AC.zip to server"
"12-04-2007 14:52:48: http://www.rsvr.com/uploadservice2.0/uploadservice.asmx/Login?uname=randd&pword=test"
"12-04-2007 14:52:53: Valid User."
"12-04-2007 14:52:53: Starting Upload:http://www.rsvr.com/uploadservice2.0/uploadservice.asmx/UploadFile?c:\test\AC.zip "
"12-04-2007 14:54:33: Upload Failed: The request was aborted: The request was canceled."
"12-04-2007 14:54:33: Upload Failed: System.Net.WebException: The request was aborted: The request was canceled.
at System.Net.WebClient.UploadFile(Uri address, String method, String fileName)
at System.Net.WebClient.UploadFile(String address, String method, String fileName)