当前位置: 首页>>代码示例>>Java>>正文


Java Core.getFileDocumentContent方法代码示例

本文整理汇总了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;
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:25,代码来源:Misc.java

示例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
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:17,代码来源:FileFromFileDocument.java

示例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;
}
 
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:26,代码来源:VisualRecognitionService.java

示例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;
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:15,代码来源:Misc.java

示例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)));		
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:10,代码来源:StringUtils.java

示例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);
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:8,代码来源:StringUtils.java


注:本文中的com.mendix.core.Core.getFileDocumentContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。