If we using multipart form data parser for uploaded form, then it saves form's files on the drive in selected location, for example like this:
var streamProvider = new MultipartFormDataStreamProvider("c:\\tmp\\uploads");
var bodyparts = await Request.Content.ReadAsMultipartAsync(streamProvider);
Who is responsible for removing temp files, which enumerated in the streamProvider.BodyPartFileNames property? If developer, then how removal process can be implemented in the best way?
I think developer working with system admins need to take care of this.
One suggetion is touse windows scheduler . We can schedule a task to remove files which are "x" number of hours/days old from your temp folder location. Scheduler task can execute an exe or a dos command to do any operations. You can create a small exe
using c# and accept parameter as number of hours and folder location . Schedule that exe with required parameter values with windows scheduler task. See here to understand how a Schedule task can be created http://windows.microsoft.com/en-us/windows7/Schedule-a-task
dtretyakov
0 Points
1 Post
Best Practice for File Upload
Jun 24, 2012 07:19 PM|LINK
If we using multipart form data parser for uploaded form, then it saves form's files on the drive in selected location, for example like this:
var streamProvider = new MultipartFormDataStreamProvider("c:\\tmp\\uploads"); var bodyparts = await Request.Content.ReadAsMultipartAsync(streamProvider);Who is responsible for removing temp files, which enumerated in the streamProvider.BodyPartFileNames property? If developer, then how removal process can be implemented in the best way?
alvingeorge
Participant
925 Points
203 Posts
Re: Best Practice for File Upload
Jun 24, 2012 09:22 PM|LINK
I think developer working with system admins need to take care of this.
One suggetion is touse windows scheduler . We can schedule a task to remove files which are "x" number of hours/days old from your temp folder location. Scheduler task can execute an exe or a dos command to do any operations. You can create a small exe using c# and accept parameter as number of hours and folder location . Schedule that exe with required parameter values with windows scheduler task. See here to understand how a Schedule task can be created http://windows.microsoft.com/en-us/windows7/Schedule-a-task
jperl
Member
6 Points
2 Posts
Re: Best Practice for File Upload
Jul 05, 2012 06:21 PM|LINK
I am also curious about this problem. Is there a way to not write to a temporary folder? If not I will look into deleting the files right after.