@AlfrescoPublicApi public class TempFileProvider extends Object
The contents of ALFRESCO_TEMP_FILE_DIR [%java.io.tmpdir%/Alfresco] are managed by this class. Temporary files and directories are cleaned by TempFileCleanerJob so that after a delay [default 1 hour] the contents of the alfresco temp dir, both files and directories are removed.
Some temporary files may need to live longer than 1 hour. The temp file provider allows special sub folders which are cleaned less frequently. By default, files in the long life folders will remain for 24 hours unless cleaned by the application code earlier.
The other contents of %java.io.tmpdir% are not touched by the cleaner job.
TempFileCleanerJob Job Data: protectHours, number of hours to keep temporary files, default 1 hour.
Modifier and Type | Class and Description |
---|---|
static class |
TempFileProvider.TempFileCleanerJob
Cleans up all Alfresco temporary files that are older than the
given number of hours.
|
Modifier and Type | Field and Description |
---|---|
static String |
ALFRESCO_LONG_LIFE_FILE_DIR
The prefix for the long life temporary files.
|
static String |
ALFRESCO_TEMP_FILE_DIR
subdirectory in the temp directory where Alfresco temporary files will go
|
static String |
SYSTEM_KEY_TEMP_DIR
the system property key giving us the location of the temp directory
|
Modifier and Type | Method and Description |
---|---|
static File |
createTempFile(InputStream in,
String namePrefix,
String nameSufix) |
static File |
createTempFile(String prefix,
String suffix)
Create a temp file in the alfresco temp dir.
|
static File |
createTempFile(String prefix,
String suffix,
File directory) |
static File |
getLongLifeTempDir(String key)
creates a longer living temp dir.
|
static File |
getSystemTempDir()
Get the Java Temp dir e.g.
|
static File |
getTempDir()
Get the Alfresco temp dir, by defaut %java.io.tempdir%/Alfresco.
|
static File |
getTempDir(String dirName)
Get the specified temp dir, %java.io.tempdir%/dirName.
|
public static final String ALFRESCO_TEMP_FILE_DIR
public static final String ALFRESCO_LONG_LIFE_FILE_DIR
public static final String SYSTEM_KEY_TEMP_DIR
public static File getSystemTempDir()
isDir == true
public static File getTempDir()
isDir == true
public static File getTempDir(String dirName)
dirName
- the name of sub-directory in %java.io.tempdir%isDir == true
public static File getLongLifeTempDir(String key)
Code using the longer life temporary files should be careful to clean up since abuse of this feature may result in out of memory/disk space errors.
key
- can be blank in which case the system will generate a folder to be used by all processes
or can be used to create a unique temporary folder name for a particular process. At the end of the process
the client can simply delete the entire temporary folder.public static File createTempFile(InputStream in, String namePrefix, String nameSufix) throws Exception
Exception
public static File createTempFile(String prefix, String suffix)
File
that will be located in the
Alfresco subdirectory of the default temp directoryALFRESCO_TEMP_FILE_DIR
,
File.createTempFile(java.lang.String, java.lang.String)
public static File createTempFile(String prefix, String suffix, File directory)
File
that will be located in the
given directoryALFRESCO_TEMP_FILE_DIR
,
File.createTempFile(java.lang.String, java.lang.String)
Copyright © 2005–2015 Alfresco Software. All rights reserved.