| Back | Main view
How to add external content type and extension resolver using IMiS/Storage Connector JAVA
Product: | IMiS/Storage Connector JAVA |
Release: | 10.3.2210, 10.2.2110, 10.1.2010 |
Date: | 02/14/2023 |
Case:
How to add external content type and extension resolver using IMiS/Storage Connector JAVA
Description:
This example demonstrates operations which adds and removes external content type and extension resolver on IMiS/Storage Connector JAVA.
Below is a description of operation for adding and removing content type and extension resolver.
1. Add external content type and extension resolver
Operation adds external content type and extension resolver on StorageConnector instance for "image/heic" content type and ".heic" extension.
JAVA
try {
StorageConnector.getInstance().setCustomContentTypeResolver(new IContentTypeResolver()
{
@Override
public String getExtension(@NotNull String contentType)
{
if ("image/heic".equals(contentType))
return ".heic";
return null;
}
@NotNull
@Override
public List<String> getExtensions(@NotNull String contentType)
{
List<String> result = new ArrayList<String>();
if ("image/heic".equals(contentType)) {
result.add(".heic");
result.add(".heif");
}
return result;
}
@Override
public String getContentType(@NotNull String extension)
{
String ext = extension.startsWith(".") ? extension.substring(1) : extension;
if ("heic".equals(ext) || "heif".equals(ext))
return "image/heic";
return null;
}
@NotNull
@Override
public List<String> getContentTypes(@NotNull String extension)
{
List<String> result = new ArrayList<String>();
String ext = extension.startsWith(".") ? extension.substring(1) : extension;
if ("heic".equals(ext) || "heif".equals(ext))
result.add("image/heic");
return result;
}
});
System.out.println("Custom content type resolver added");
}
catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
2. Remove external content type and extension resolver
Operation removes external content type and extension resolver on StorageConnector instance.
JAVA
try {
StorageConnector.getInstance().setCustomContentTypeResolver(null);
System.out.println("Custom content type resolver removed");
}
catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
Related Documents:
| Back | Main view