|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface File
Represents a file in the WebDAV repository.
Defines methods that WebDAV server file items must implement.
In addition to methods provided by HierarchyItem
this interface also provides methods for reading and writing file content.
getContentType()> method must return the MIME type of the file.
| Method Summary | |
|---|---|
long |
getContentLength()
Gets the size of the file content in bytes. |
java.lang.String |
getContentType()
Gets the media type of the file. |
void |
read(java.io.OutputStream output,
long startIndex,
long count)
Writes the content of the file to the specified stream. |
void |
write(java.io.InputStream content,
java.lang.String contentType,
long startIndex,
long totalFileSize)
Saves the content of the file from the specified stream to the WebDAV repository. |
| Methods inherited from interface com.ithit.webdav.server.HierarchyItem |
|---|
copyTo, delete, getCreated, getModified, getName, getPath, getProperties, getPropertyNames, moveTo, updateProperties |
| Method Detail |
|---|
java.lang.String getContentType()
throws ServerException
Mime-type provided by this method is returned in a Content-Type header with GET request.
When deciding which action to perform when downloading a file some WebDAV clients and browsers (such as Internet Explorer) rely on file extension, while others (such as Firefox) rely on Content-Type header returned by server. For identical behavior in all browsers and WebDAV clients your server must return a correct mime-type with a requested file.
ServerException - In case of an error.
long getContentLength()
throws ServerException
ServerException - In case of an error.
void read(java.io.OutputStream output,
long startIndex,
long count)
throws ServerException,
java.io.IOException
Client application can request only a part of a file specifying Range header. Download managers may use this header to download single file using several threads at a time.
output - Output stream.startIndex - Zero-bazed byte offset in file content at which to begin copying bytes to the output stream.count - Number of bytes to be written to the output stream.
ServerException - In case of an error.
java.io.IOException - I/O exception occurred.
void write(java.io.InputStream content,
java.lang.String contentType,
long startIndex,
long totalFileSize)
throws LockedException,
ServerException,
java.io.IOException
If totalContentLength is -1 then content parameter
contains entire file content. startIndex parameter
is always 0 in this case.
The Java WebDAV Server Engine can process two types of upload requests:
To provide information about what segment of a file is being uploaded rich client application will attach optional Content-Range: bytes XXX-XXX/XXX header to PUT request.
The following example demonstrates upload to WebDAV server using POST with multipart encoding. The file will be created in /mydocs/ folder.
<html>
<head><title>POST Upload to WebDAV Server</title></head>
<body>
<form action="/mydocs/" method="post" enctype="multipart/form-data">
<input type="file" name="dummyname" /><br />
<input type="submit" />
</form>
</body>
</html>
content - InputStream to read the content of the file from.contentType - Indicates media type of the file.startIndex - Index in file to which corresponds first byte in content.totalFileSize - Total size of the file being uploaded. -1 if size is unknown.
LockedException - File was locked and client did not provide lock token.
ServerException - In case of an error.
java.io.IOException - I/O error.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||