public class MediaUtil
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
MediaUtil.PublicMediaURLRenderer |
static interface |
MediaUtil.SecureMediaURLRenderer |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DUMMY_FILE_NAME |
static java.lang.String |
FILE_SEP |
static java.lang.String |
MEDIA_DATA_DIRS |
static java.lang.String |
MEDIA_READ_DIR |
static java.lang.String |
URL_HAS_DATA |
static java.lang.String |
URL_IS_EMPTY
If the URL contains this string, the URL is empty.
|
| Constructor and Description |
|---|
MediaUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
addLeadingFileSepIfNeeded(java.lang.String path)
Adds the leading file separator to the path if it doesn't contain one already.
|
static java.lang.String |
addTrailingFileSepIfNeeded(java.lang.String path)
Adds the trailing file separator to the path if it doesn't contain one already.
|
static java.lang.String |
appendFileNameToDirName(java.lang.String dirname,
java.lang.String filename) |
static java.lang.String |
assemblePublicMediaURL(java.lang.String rawUrl) |
static java.lang.String |
assembleSecureMediaURL(MediaSource media) |
static java.io.File |
composeOrGetParent(java.io.File parent,
java.lang.String child)
Builds the file from parent file and child pathname which can be directory or file.
|
static java.io.File |
concatDirectoryWithFolder(java.io.File dir,
MediaFolder subFolder)
Concatenates given directory with given folder.
|
static long |
copy(java.io.InputStream is,
java.util.Collection<java.io.OutputStream> os)
Copy the data from the Inputstream to a Collection of Outputstreams.
|
static long |
copy(java.io.InputStream is,
java.util.Collection<java.io.OutputStream> outStreams,
boolean closeOutputStreams)
Copy the data from the InputStream to a Collection of OutputStreams.
|
static long |
copy(java.io.InputStream is,
java.io.OutputStream os)
Copy the data from the Inputstream to the Outputstream.
|
static long |
copy(java.io.InputStream is,
java.io.OutputStream os,
boolean closeOutputStream)
Copy the data from the Inputstream to the Outputstream.
|
static void |
copyMediaData(Media src,
Media tgt)
|
static MediaUtil.PublicMediaURLRenderer |
getCurrentPublicMediaURLRenderer() |
static MediaUtil.SecureMediaURLRenderer |
getCurrentSecureMediaURLRenderer() |
static java.lang.String |
getFileExtension(java.lang.String filename)
Returns the file name extension (lowercase) or, if no '.' is found, the whole file name (without case change).
|
static java.lang.String |
getLocalMediaWebRootUrl()
Returns local media web URL root URL.
|
static java.io.File |
getLocalStorageDataDir() |
static java.util.List<java.io.File> |
getLocalStorageReplicationDirs()
Reads directories defined in media.replication.dirs.
|
static java.io.File |
getMediaReadDir()
Returns the media read directory.
|
static java.lang.String |
getSystemDir() |
static java.io.File |
getTenantMediaReadDir()
Same as
getMediaReadDir() but including the current tenant subdirectory. |
static boolean |
isCurrentRequestSSLModeEnabled() |
static boolean |
isFileNamePrettyURLCompatible(java.lang.String realFileName) |
static boolean |
isZipRelatedMime(java.lang.String mime)
Deprecated.
since ages - use
MimeService.isZipRelatedMime(String) instead. |
static java.lang.String |
normalizeRealFileName(java.lang.String realFileName) |
static java.lang.String |
removeFileExtension(java.lang.String fileName) |
static java.lang.String |
removeLeadingFileSepIfNeeded(java.lang.String path)
Removes leading separator from the path if exists.
|
static java.lang.String |
removeTrailingFileSepIfNeeded(java.lang.String path)
Removes trailing separator from the path if it exists.
|
static void |
setCurrentPublicMediaURLRenderer(MediaUtil.PublicMediaURLRenderer renderer) |
static void |
setCurrentRequestSSLModeEnabled(boolean enabled) |
static void |
setCurrentSecureMediaURLRenderer(MediaUtil.SecureMediaURLRenderer renderer) |
static void |
unsetCurrentPublicMediaURLRenderer() |
static void |
unsetCurrentRequestSSLModeEnabled() |
static void |
unsetCurrentSecureMediaURLRenderer() |
public static final java.lang.String URL_IS_EMPTY
public static final java.lang.String URL_HAS_DATA
public static final java.lang.String MEDIA_DATA_DIRS
public static final java.lang.String MEDIA_READ_DIR
public static final java.lang.String DUMMY_FILE_NAME
public static final java.lang.String FILE_SEP
public static boolean isCurrentRequestSSLModeEnabled()
public static void setCurrentRequestSSLModeEnabled(boolean enabled)
public static void unsetCurrentRequestSSLModeEnabled()
public static void setCurrentSecureMediaURLRenderer(MediaUtil.SecureMediaURLRenderer renderer)
public static void unsetCurrentSecureMediaURLRenderer()
public static MediaUtil.SecureMediaURLRenderer getCurrentSecureMediaURLRenderer()
public static void setCurrentPublicMediaURLRenderer(MediaUtil.PublicMediaURLRenderer renderer)
public static void unsetCurrentPublicMediaURLRenderer()
public static MediaUtil.PublicMediaURLRenderer getCurrentPublicMediaURLRenderer()
@Deprecated public static boolean isZipRelatedMime(java.lang.String mime)
MimeService.isZipRelatedMime(String) instead.public static java.lang.String assembleSecureMediaURL(MediaSource media)
public static java.lang.String assemblePublicMediaURL(java.lang.String rawUrl)
public static final java.io.File getMediaReadDir()
getTenantMediaReadDir()public static final java.io.File getTenantMediaReadDir()
getMediaReadDir() but including the current tenant subdirectory.getMediaReadDir()public static java.util.List<java.io.File> getLocalStorageReplicationDirs()
public static java.io.File getLocalStorageDataDir()
public static java.io.File composeOrGetParent(java.io.File parent,
java.lang.String child)
public static java.lang.String getSystemDir()
public static long copy(java.io.InputStream is,
java.io.OutputStream os)
throws java.io.IOException
is - the Inputstreamos - the Outputstreamjava.io.IOException - when an error in the inputstream occurs; an error in the outputstream will be catched and printed to
the commandlinepublic static long copy(java.io.InputStream is,
java.io.OutputStream os,
boolean closeOutputStream)
throws java.io.IOException
is - the Inputstreamos - the OutputstreamcloseOutputStream - set to false if the Outputstream should not be closed afterwards.java.io.IOException - when an error in the inputstream occurs; an error in the outputstream will be catched and printed to
the commandlinepublic static long copy(java.io.InputStream is,
java.util.Collection<java.io.OutputStream> os)
throws java.io.IOException
is - the Inputstreamos - a Collection of Outputstreamsjava.io.IOException - when an error in the inputstream occurs; an error in the outputstreams will be catched and printed to
the commandlinepublic static long copy(java.io.InputStream is,
java.util.Collection<java.io.OutputStream> outStreams,
boolean closeOutputStreams)
throws java.io.IOException
is - the InputStreamoutStreams - a Collection of OutputStreamscloseOutputStreams - set to false if the OutputStream should not be closed afterwards.java.io.IOException - when an error in the input stream occurs; an error in the output streams will be caught and printed to
the command linepublic static java.lang.String getLocalMediaWebRootUrl()
public static java.lang.String appendFileNameToDirName(java.lang.String dirname,
java.lang.String filename)
public static final java.lang.String getFileExtension(java.lang.String filename)
filename - the file name to get extension frompublic static java.lang.String normalizeRealFileName(java.lang.String realFileName)
public static boolean isFileNamePrettyURLCompatible(java.lang.String realFileName)
public static java.io.File concatDirectoryWithFolder(java.io.File dir,
MediaFolder subFolder)
dir - directorysubFolder - folder whose path will be added to directorypublic static java.lang.String addTrailingFileSepIfNeeded(java.lang.String path)
path - the pathpublic static java.lang.String removeTrailingFileSepIfNeeded(java.lang.String path)
path - the pathpublic static java.lang.String removeLeadingFileSepIfNeeded(java.lang.String path)
path - the pathpublic static java.lang.String addLeadingFileSepIfNeeded(java.lang.String path)
path - the pathpublic static java.lang.String removeFileExtension(java.lang.String fileName)
Copyright © 2018 SAP SE. All Rights Reserved.