DEXTUpload.NET Professional
menu toggleProduct Information > Clean operation guide of temporary files

Clean operation guide of temporary files

The DEXTUpload.NET Professional product has an intermediate step of generating the always temporary files when uploading files.

The "FileUploadMonitorModule" module creates temporary files with the data transferred to the server using HTTP protocol from the client(browser, Third-party or other program). Temporary files in aspx pages, ashx generic handlers or the action methods of controllers in MVC environment can be accessed through the "FileElement" object(implementing the "IFileManagement" interface). The "FileElement" object can be obtained through the "FileUpload' or "DEXTPostedFile" object, this object has the "Save, SaveAs" methods to save the file to the final destination.

Uploading

Temporary files are named with "DEXT-*.tmp". These files will be removed after calling the "Save, SaveAs" methods of "FileElement". On the other hand, if you do not perform the save operation, temporary files will remain. The remaining temporary files are automatically deleted from the components without deleting directly from your code, you should compose codes to be able to call the "Dispose" method of the "FileUpload". In the MVC, should be "UseDEXTAttribute" attribute is decorated in action method.

# In a typical Webform environment

// The Dispose method is called internally when exiting the using statement.
using (var dext = new FileUpload())
{
    ...
}

// or
var dext = null as FileUpload;
try
{
    dext = new FileUpload();
    ...
}
catch ...
finally
{
    if (dext != null) dext.Dispose();
}
# In an MVC

// At the end of the action method, delete the temporary file by "UseDEXTAttribute".
[UseDEXT]
public ActionResult Upload(List<DEXTPostedFile> files)
{
    ...
}

If you do not have the treatment as described above, so the temporary files are remaining. (Also the code of the configuration of the problem, it may be temporary files are left, if an error occurs in the process of analyzing the "FileUploadMonitorModule" module, the target will be remaining as junk files that are not removed.)

In the upload environment of large files, it is possible that these junk files occurs frequently. During the upload of large files, in order to create a complete temporary files, the product combines the data of the request, if this work is interrupted by user actions or errors, the temporary files become junk files(the original file and the other). These junk files can not be detected in aspx pages, ashx generic handlers or the action methods, will always remain.

To delete temporary files and junk files that have not been deleted, it must drive the cleaner in the module.

Cleaning

In order to drive the cleaner, it is necessary to set the value of the "enableCleaner" attribute of the <settings> element of the <dextupload.net> section in the "Web.config" file.

<dextupload.net>
  <settings 
    tempPath="~/files/temp" 
    ...
    cleanerIntervalTime="60000"
    timeAgoForCleaning="24"
    enableCleaner="true"
    ... />
</dextupload.net>

Because the default value of the "enableCleaner" is false, the cleaner does not operate basically. If this property is set to true, the cleaner is driven at the time of the first upload.

The cleaner prepares to remove the junk files by using "cleanerIntervalTime, timeAgoForCleaning" attributes. For example, if the value of "cleanerIntervalTime" is 60000 and the value of "timeAgoForCleaning" is 24, the cleaner will remove resources of all temporary files(DEXT-*.tmp, DEXT-*.tmp.EXTENSION) past 24 hours from the temporary folder pointed to "tempPath" attribute every minute.

In the case of uploading of large files, if some temporary files exist, it is possible to re-upload files continually even after a few days. However, if cleaner is working, the files past the specified time of the "timeAgoForCleaning" attribute will be deleted all.

The cleaner deletes the files remained by using the "Keep" method of "DEXTUpload.NET.FileElement" class.

When sharing the same temporary folder of many web applications, in the course of multiple processes to remove the temporary files may be made I/O errors.