I'm wondering in what way HttpContext.Request keeps uploaded files in memory.
Does is it hold them in RAM only or writes them in some temp dir on the HDD?
How to control this process?
They write the file to a temp directory. You see almost no memory use increase when uploading a file. When using this control you can't choose any other way to do it.
Related
I am having hard time figuring out how to get the file InputStream from file upload Post request to server, before it gets completely loaded into memory.
This is not problematic for smaller files, but I am worried what happens after trying to upload a larger file (1 or more GB). I found a possible solution with using HttpContext.Request.GetBufferlessInputStream(true), but this stream includes the whole request not just the uploading file and if I use it to upload a file for example into the Azure Blob Storage or anywhere else I end up with the corrupted file. I also lose all the information about the file (file name, size, etc.).
Is there any convenient way of uploading a large file to server without filling its memory? I would like to get the stream and then use it to upload a file anywhere in chunks.
Thank you.
I used DevExpress UploadControl for a similar task. It supports large file upload by chunks. A temporary file is saved on a server hard drive and you can get it using FileSteam without full loading in server memory. It also supports direct upload to Azure, Amazon and Dropbox.
The same is true for their MVC Upload control.
In my application,user can upload some doc files to the server,and I want user who do not install ms office can read these documents,so I want to convert the .doc to html and then save the html(binary stream) to oracle db.
I wonder if there is a best pratice to implement this?
Someone tell me to use the com object provoided by the office assembly,it seems that it will transfer the .doc file to a .html file,so I have to save the .html file to db and delete the temp .html file,I want to know if I can save it in db directly?
You might need to give everyone a bit more information...
I assume you're using a server side technology? Which one?
What database are you using?
The chances are if the COM object is writing it to a file, you will - like you say, just need to copy that into the DB, and delete the temp file.
IMHO - There should be nothing wrong with saving to temp file and outputting that to DB (if you could save to memory that would be even better!)
I'm working on an asp.net /c# app
I need my app to allow users to upload .XLS files (located on the user machine).
How can i read data from the .XLS file but without saving the file on server?
tks
In order to be able to do something with the file on the server (eg using ASP.net ) you will have to at least temporarily save the file on the server. Although an apache module might let you interupt the stream as it is uploaded, but thats probably a bit ott.
There MAY be something you could do in Javascript but I doubt it.
An idea would be to parse .csv files, if it possible. I can send example.
Also you can parse .XLS files through interop excel dll. But it very slow method.
I know this is a bit like how long is a piece of string question, but I'm wondering how big some peoples ASP.NET Temporary Files folder, gets. I wish to move this folder to a RAM DISK so I'm trying to see how big this should be set, to.
eg. <compilation tempDirectory=“R:\ASP.Net Temporary Folder\” debug=“false“>
This is only for my DEVELOPMENT Machine (to help speed up compiling -> temp crap goes to ram instead of the Disk).
Is 256MB big enough? What about file uploading? where do those files (temporarily) go?
Cheers :)
From my experience on my web server and on many sites 256 MB is big enough for one site.
The 10Mg files (only aspx and cs) product about 20-40Mg files on temporary (plus your files on bin directory).
I check my server that runs many asp.net v4 and v3.5 sites and I have temporary dirs up to 40Mg on the very huge projects. Most of the sites use 1-4Gb.
The uploading files not go to this temporary file, but they go where you have set to go on upload.
Hope this help you.
I have made a upload page to upload dll to server, many of the times the dll gets corrupt on upload.
How do I detect that the file uploaded is corrupt or not in asp.net?
There's no way to detect a corruption without something else as a reference (eg, MD5 sum). Any file can contain any data, so simply inspecting a file without any semantics at all won't tell you anything.
Is it only dll files that get corrupted? Not sure why this would be the case, but zipping them might help? You would need to create some kind of late binding test method or something to test the dll.