|
skogenGump wrote: I have a worry that this solution (whilst nice and neat) will suffer with the exact same problem, you'll have a 200mb object in server memory.
That make no sense, and if asp.net server does that its quite stupid. I dunno exactly but I don't think thats how file upload works, the server should also write bytes even the request is being sent.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
modified on Wednesday, October 6, 2010 11:01 AM
|
|
|
|
|
There are some good reasons why it behaves this way, what if the user that ASP.Net is running as doesn't have permissions to write to the storage area for example ?
There is a way to get around this by using reflection to obtain the WorkerRequest object from the HttpContext object. this gives you access to the incoming byte stream. and you can use WorkerRequest.ReadEntityBody(...) to get the bytes and write them directly to the file system.
|
|
|
|
|
skogenGump wrote: what if the user that ASP.Net is running as doesn't have permissions to write to the storage area for example ?
The header is the first thing that is send and receive both by server and client. And header contains authentication cookie, so if user dont have permission asp.net will not let it write a single byte. Same with IO permissions which was your actual question. If the directory dont have write permission, you will sure get a nice error.
skogenGump wrote: There is a way to get around this by using reflection to obtain the WorkerRequest object from the HttpContext object. this gives you access to the incoming byte stream. and you can use WorkerRequest.ReadEntityBody(...) to get the bytes and write them directly to the file system.
dude why you digging holes for nothing. Here is simple, just use HttpPostedFile.SaveAs or HttpPostedFile.InputStream
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Errm, you might want to go and actually have a look what HttpPostedFile *does* before telling me off.
It doesn't give you access to the byte stream that comes from the client, it copies it all into memory and holds it internally as a HttpInputStream.
As soon as you access that, the Data it holds is read into a byte[] and kept in memory, till you dispose it.
If you don't like it, don't blame me - go and read the source code, reflector is free.
However, if you run in an environment where you can't afford to have hundreds of megabytes of filestream sitting in your gen0 heap, use the method I suggested.
|
|
|
|
|
did I blame anything to you ? I simply replied to your strange question and suggested you something. And about HttpPostedFile, you better read its source *again*. Its just a simple class that does nothing but hold variables and a simple writing method. I dunno how it being created in Request or from where it read the bytes as I said in one of above post.
skogenGump wrote: However, if you run in an environment where you can't afford to have hundreds of megabytes of filestream sitting in your gen0 heap, use the method I suggested.
Sure, I will think about it later.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
skogenGump wrote: I have a worry that this solution (whilst nice and neat) will suffer with the exact same problem, you'll have a 200mb object in server memory.
http://support.microsoft.com/?id=323246[^]
"During the upload process, ASP.NET loads the whole file in memory before the user can save the file to the disk. Therefore, the process may recycle because of the memoryLimit attribute of the processModel tag in the Machine.config file. The memoryLimit attribute specifies the percentage of physical memory that the ASP.NET worker process can exhaust before the process is automatically recycled. Recycling prevents memory leaks from causing ASP.NET to crash or to stop responding."
Now, I hate it to accept that, why the flip asp.net does that. Why not just give the direct stream.
BTW, thanks for that info...but you've just increased my todo list which wont finish even in thousands years
Edit :
This will help you, How to upload huge files[^]
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
I have written a large file uploader that works around this problem, but it's not modularised yet; not enough hours in the day.
|
|
|
|
|
Is it joke? Are u planning to request server every 0.2 second? This solution have a big trouble with scaleability.
|
|
|
|
|
Do you have any suggestions?
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
Bunch of HTML and JavaScript don't allow to get percent of uploading process. Furthermore, uploading process customization is brain cancer of using just html+javaScript on client side web programmers. But happily, we can use Silverlight or flash for do it very simple and without any hacks.
|
|
|
|
|
Thanks for you comments
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
Yupp, thats what I was thinking...but both have advantages.
In flash or SL, you cant get the actual progress, the progress you get is of the local writer, there is no progress update for actual writer to server.
However, in his uploader same as ComponentArt tech, gets the actual progress. It would be good if we increase the time to check the progress.
Btw, I'm still using FancyUpload, waiting for best of best solution.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen W.K
Do you perhaps have a working ASP.NET sample of 'FancyUpload'
Johan
(Who is General Failure and what is he doing on my machine)
|
|
|
|
|
Its quite easy, go to its site and do exactly what it says except php part and in the url of fancyupload, set it any of yours page url and in page load, save the file as normal(Request.Files ).
But remember, since its flash it doesnt send authentication and session cookies, I'm using a handler that uses an encypted FormTicket sent through querystring.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Yes the request time can be reduced
|
|
|
|
|
Excellent article.
Thank you very much
|
|
|
|
|
Thanks,
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
I was searching similar from long time.
Vikas Agarwal
|
|
|
|
|
I also tried to find solution from long time..
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
Great Article Dude!!Have my 5.
One feedback: Some of images of code are not looking good better if you replace it by the pre tag.
|
|
|
|
|
You are absolutely right.
but when i was posting an article and write a code inside the
<pre lang="html">
tag
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
When i was written article i use
tag and i have html code with Button and IFRANE but the problem is it will drawing button on site so it's very funny ;P ;P then i decided to use image instead of code snippet inside the pre tag
Pleas do let me know what was the problem for rendering HTML when it is inside the <pre> tag
Thakns,
<div class="signature"><font style="font-family: calibri">
suna<font style="color: rgba(255, 0, 0, 1)">Sa</font><font style="color: rgba(0, 128, 0, 1)">Ra</font> <font style="color: rgba(0, 0, 255, 1)">Im</font>dadhusen
+91 99095 44184
+91 02767 284464</font></div>
|
|
|
|
|
very nice. I try it is run
|
|
|
|
|
Please do let me know your suggestion, comments regrading improvement of the artical.
Thanks,
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
Cool and useful, thanks for sharing.
Wanting to see more articles like this from you. Keep it up
cheers,
marcelo
|
|
|
|