本文整理汇总了Java中com.mendix.core.Core.getFileDocumentContent方法的典型用法代码示例。如果您正苦于以下问题:Java Core.getFileDocumentContent方法的具体用法?Java Core.getFileDocumentContent怎么用?Java Core.getFileDocumentContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mendix.core.Core
的用法示例。
在下文中一共展示了Core.getFileDocumentContent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileSize
import com.mendix.core.Core; //导入方法依赖的package包/类
public static Long getFileSize(IContext context, IMendixObject document)
{
final int BUFFER_SIZE = 4096;
long size = 0;
if (context != null) {
InputStream inputStream = null;
byte[] buffer = new byte[BUFFER_SIZE];
try {
inputStream = Core.getFileDocumentContent(context, document);
int i;
while ((i = inputStream.read(buffer)) != -1)
size += i;
} catch (IOException e) {
Core.getLogger("FileUtil").error(
"Couldn't determine filesize of FileDocument '" + document.getId());
} finally {
IOUtils.closeQuietly(inputStream);
}
}
return size;
}
示例2: executeAction
import com.mendix.core.Core; //导入方法依赖的package包/类
@Override
public Boolean executeAction() throws Exception
{
this.fileDocument = __fileDocument == null ? null : system.proxies.FileDocument.initialize(getContext(), __fileDocument);
// BEGIN USER CODE
File output = new File(targetFile);
FileOutputStream fos = new FileOutputStream(output);
InputStream is = Core.getFileDocumentContent(getContext(),
fileDocument.getMendixObject());
IOUtils.copy(is, fos);
fos.close();
is.close();
return true;
// END USER CODE
}
示例3: createImageFile
import com.mendix.core.Core; //导入方法依赖的package包/类
private static File createImageFile(IContext context, Image image) throws MendixException {
final String imageFileExtension = FilenameUtils.getExtension(image.getName());
if(!WATSON_DETECT_FACES_SUPPORTED_IMAGE_EXTENSION_JPG.equals(imageFileExtension.toLowerCase()) &&
!WATSON_DETECT_FACES_SUPPORTED_IMAGE_EXTENSION_PNG.equals(imageFileExtension.toLowerCase()) &&
!WATSON_DETECT_FACES_SUPPORTED_IMAGE_EXTENSION_ZIP.equals(imageFileExtension.toLowerCase())){
final String errorMessage = "The input file doesn't have a valid extension (jpg, png or zip) :" + image.getName();
LOGGER.error(errorMessage);
throw new MendixException(errorMessage);
}
final File imageToDetectFaces = new File(Core.getConfiguration().getTempPath() + DETECT_FACES_FILENAME);
try(final InputStream stream = Core.getFileDocumentContent(context, image.getMendixObject());) {
Files.copy(stream, imageToDetectFaces.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
LOGGER.error("There was a problem with the image file: " + imageToDetectFaces.getPath(), e);
throw new MendixException(e);
}
return imageToDetectFaces;
}
示例4: duplicateFileDocument
import com.mendix.core.Core; //导入方法依赖的package包/类
public static Boolean duplicateFileDocument(IContext context, IMendixObject toClone, IMendixObject target) throws Exception
{
if (toClone == null || target == null)
throw new Exception("No file to clone or to clone into provided");
MendixBoolean hasContents = (MendixBoolean) toClone.getMember(context, FileDocument.MemberNames.HasContents.toString());
if (!hasContents.getValue(context))
return false;
InputStream inputStream = Core.getFileDocumentContent(context, toClone);
Core.storeFileDocumentContent(context, target, (String) toClone.getValue(context, system.proxies.FileDocument.MemberNames.Name.toString()), inputStream);
return true;
}
示例5: base64EncodeFile
import com.mendix.core.Core; //导入方法依赖的package包/类
public static String base64EncodeFile(IContext context, FileDocument file) throws IOException
{
if (file == null)
throw new IllegalArgumentException("Source file is null");
if (!file.getHasContents())
throw new IllegalArgumentException("Source file has no contents!");
InputStream f = Core.getFileDocumentContent(context, file.getMendixObject());
return new String(Base64.encodeBase64(IOUtils.toByteArray(f)));
}
示例6: stringFromFile
import com.mendix.core.Core; //导入方法依赖的package包/类
public static String stringFromFile(IContext context, FileDocument source) throws IOException
{
if (source == null)
return null;
InputStream f = Core.getFileDocumentContent(context, source.getMendixObject());
return org.apache.commons.io.IOUtils.toString(f);
}