public class FSUploadManager extends TimerTask implements UploadManager, ThreadSafe, Initializable, Contextualizable, LogEnabled, Disposable
UploadManager
which stores uploaded files into the
uploads-user
directory located in Ametys home
Note that this implementation is not cluster safe.
Modifier and Type | Class and Description |
---|---|
protected static class |
FSUploadManager.FSUpload
Upload implementation on file system. |
Modifier and Type | Field and Description |
---|---|
protected Context |
_context
Context.
|
protected File |
_globalUploadsDir
Global uploads directory.
|
private Logger |
_logger
Logger available to subclasses.
|
protected Timer |
_timer
Timer.
|
static String |
UPLOADS_DIRECTORY
The path to the global uploads directory relative to ametys home
|
ROLE
Constructor and Description |
---|
FSUploadManager() |
Modifier and Type | Method and Description |
---|---|
protected File |
_getUploadDir(String login,
String id)
Retrieves the upload directory for a login and an upload id.
|
void |
contextualize(Context context) |
void |
dispose() |
void |
enableLogging(Logger logger) |
Upload |
getUpload(UserIdentity user,
String id)
Retrieves a previous file uploaded by an user.
|
void |
initialize() |
void |
run() |
Upload |
storeUpload(UserIdentity user,
String filename,
InputStream is)
Stores a file uploaded by an user.
|
cancel, scheduledExecutionTime
public static final String UPLOADS_DIRECTORY
protected File _globalUploadsDir
public FSUploadManager()
public void enableLogging(Logger logger)
enableLogging
in interface LogEnabled
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void initialize() throws Exception
initialize
in interface Initializable
Exception
public Upload storeUpload(UserIdentity user, String filename, InputStream is) throws IOException
UploadManager
storeUpload
in interface UploadManager
user
- the user.filename
- the upload filename.is
- the upload data.IOException
- if an error occurs.public Upload getUpload(UserIdentity user, String id) throws NoSuchElementException
UploadManager
getUpload
in interface UploadManager
user
- the user.id
- the upload id.NoSuchElementException
- if there is no upload
for this parameters.public void dispose()
dispose
in interface Disposable
protected File _getUploadDir(String login, String id)
login
- the login.id
- the upload id.