Class FileServingHelper
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.filestorage.FileServingHelper
-
public class FileServingHelper extends Object
Static methods to help when serving uploaded files.
-
-
Field Summary
Fields Modifier and Type Field Description static StringPROPERTY_DEFAULT_NAMESPACE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetBytestreamAliasUrl(String uri, String filename, javax.servlet.ServletContext ctx)Combine the URI and the filename to produce a relative URL for the file (relative to the context of the webapp).static StringgetBytestreamUri(String path, javax.servlet.ServletContext ctx)Take a relative URL (relative to the context of the webapp) and produce the URI for the file bytestream.
-
-
-
Field Detail
-
PROPERTY_DEFAULT_NAMESPACE
public static final String PROPERTY_DEFAULT_NAMESPACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getBytestreamAliasUrl
public static String getBytestreamAliasUrl(String uri, String filename, javax.servlet.ServletContext ctx)
Combine the URI and the filename to produce a relative URL for the file (relative to the context of the webapp). The filename will be URLEncoded as needed.
This should involve stripping the default namespace from the front of the URL, replacing it with the file prefix, and adding the filename to the end.
- Returns:
- the translated URL, if the URI was in the default namespace,
- the original URI, if it wasn't in the default namespace,
- null, if the original URI or the filename was null.
-
getBytestreamUri
public static String getBytestreamUri(String path, javax.servlet.ServletContext ctx)
Take a relative URL (relative to the context of the webapp) and produce the URI for the file bytestream.
This should involve removing the filename from the end of the URL, and replacing the file prefix with the default namespace.
- Returns:
- the URI, or
nullif the URL couldn't be translated.
-
-