Class SlingFileUploadHandler
Simple example:
<form action="/home/admin" method="POST" enctype="multipart/form-data">
<input type="file" name="./portrait" />
</form>
this will create a nt:file node below "/home/admin" if the node type of
"admin" is (derived from) nt:folder, a nt:resource node otherwise.
Filename example:
<form action="/home/admin" method="POST" enctype="multipart/form-data">
<input type="file" name="./*" />
</form>
same as above, but uses the filename of the uploaded file as name for the
new node.
Type hint example:
<form action="/home/admin" method="POST" enctype="multipart/form-data">
<input type="file" name="./portrait" />
<input type="hidden" name="./portrait@TypeHint" value="my:file" />
</form>
this will create a new node with the type my:file below admin. if the hinted
type extends from nt:file an intermediate file node is created otherwise
directly a resource node.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteChunks
(Resource rsrc) Delete all chunks saved within a resource.getLastChunk
(Resource rsrc) Get the lastSlingPostConstants.NT_SLING_CHUNK_NODETYPE
Resource
.void
setFile
(Resource parent, RequestProperty prop, List<Modification> changes) Uses the file(s) in the request parameter for creation of new nodes.void
setServletContext
(javax.servlet.ServletContext servletContext)
-
Constructor Details
-
SlingFileUploadHandler
public SlingFileUploadHandler()
-
-
Method Details
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext) -
deleteChunks
Delete all chunks saved within a resource. If no chunks exist, it is no-op.- Parameters:
rsrc
- the resource- Throws:
PersistenceException
- in case of problems
-
getLastChunk
Get the lastSlingPostConstants.NT_SLING_CHUNK_NODETYPE
Resource
.- Parameters:
rsrc
-Resource
containingSlingPostConstants.NT_SLING_CHUNK_NODETYPE
Resource
s- Returns:
- the
SlingPostConstants.NT_SLING_CHUNK_NODETYPE
chunk resource.
-
setFile
public void setFile(Resource parent, RequestProperty prop, List<Modification> changes) throws PersistenceException Uses the file(s) in the request parameter for creation of new nodes. if the parent node is a nt:folder a new nt:file is created. otherwise just a nt:resource. if thename
is '*', the filename of the uploaded file is used.- Parameters:
parent
- the parent nodeprop
- the assembled property infochanges
- the changes- Throws:
PersistenceException
- if an error occurs
-