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


Java MimetypeMap.MIMETYPE_BINARY属性代码示例

本文整理汇总了Java中org.alfresco.repo.content.MimetypeMap.MIMETYPE_BINARY属性的典型用法代码示例。如果您正苦于以下问题:Java MimetypeMap.MIMETYPE_BINARY属性的具体用法?Java MimetypeMap.MIMETYPE_BINARY怎么用?Java MimetypeMap.MIMETYPE_BINARY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.alfresco.repo.content.MimetypeMap的用法示例。


在下文中一共展示了MimetypeMap.MIMETYPE_BINARY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ContentData

/**
 * Create a compound set of data representing a single instance of <i>content</i>.
 * <p>
 * In order to ensure data integrity, the {@link #getMimetype() mimetype}
 * must be set if the {@link #getContentUrl() content URL} is set.
 * 
 * @param contentUrl the content URL.  If this value is non-null, then the
 *      <b>mimetype</b> must be supplied.
 * @param mimetype the content mimetype.  This is mandatory if the <b>contentUrl</b> is specified.
 * @param size the content size.
 * @param encoding the content encoding.  This is mandatory if the <b>contentUrl</b> is specified.
 * @param locale the locale of the content (may be <tt>null</tt>).  If <tt>null</tt>, the
 *      {@link I18NUtil#getLocale() default locale} will be used.
 */
public ContentData(String contentUrl, String mimetype, long size, String encoding, Locale locale)
{
    if (contentUrl != null && (mimetype == null || mimetype.length() == 0))
    {
        mimetype = MimetypeMap.MIMETYPE_BINARY;
    }
    checkContentUrl(contentUrl, mimetype, encoding);
    this.contentUrl = contentUrl;
    this.mimetype = mimetype;
    this.size = size;
    this.encoding = encoding;
    if (locale == null)
    {
        locale = I18NUtil.getLocale();
    }
    this.locale = locale;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:31,代码来源:ContentData.java

示例2: getContentInfo

/**
    * Returns the basic content info from the request.
    * @param req WebScriptRequest
    * @return BasicContentInfo
    */
   private BasicContentInfo getContentInfo(WebScriptRequest req) {
   	
	String encoding = "UTF-8";
	String contentType = MimetypeMap.MIMETYPE_BINARY;
	
	if (StringUtils.isNotEmpty(req.getContentType()))
	{
		MediaType media = MediaType.parseMediaType(req.getContentType());
		contentType = media.getType()+'/'+media.getSubtype();
		if (media.getCharSet() != null)
		{
			encoding = media.getCharSet().toString();
		}			
	}

       return new ContentInfoImpl(contentType, encoding, -1, Locale.getDefault());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:ResourceWebScriptPut.java

示例3: streamContentImpl

protected void streamContentImpl(WebScriptRequest req, WebScriptResponse res, 
        ContentReader reader, NodeRef nodeRef, QName propertyQName, 
        boolean attach, Date modified, String eTag, String attachFileName)
        throws IOException
{
    delegate.setAttachment(req, res, attach, attachFileName);

    // establish mimetype
    String mimetype = reader.getMimetype();
    String extensionPath = req.getExtensionPath();
    if (mimetype == null || mimetype.length() == 0)
    {
        mimetype = MimetypeMap.MIMETYPE_BINARY;
        int extIndex = extensionPath.lastIndexOf('.');
        if (extIndex != -1)
        {
            String ext = extensionPath.substring(extIndex + 1);
            mimetype = mimetypeService.getMimetype(ext);
        }
    }

    // set mimetype for the content and the character encoding + length for the stream
    res.setContentType(mimetype);
    res.setContentEncoding(reader.getEncoding());
    res.setHeader("Content-Length", Long.toString(reader.getSize()));

    // set caching
    Cache cache = new Cache();
    cache.setNeverCache(false);
    cache.setMustRevalidate(true);
    cache.setMaxAge(0L);
    cache.setLastModified(modified);
    cache.setETag(eTag);
    res.setCache(cache);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:35,代码来源:ContentInfo.java

示例4: streamContent

/**
 * Streams content back to client from a given File.
 * 
 * @param req               The request
 * @param res               The response
 * @param file              The file whose content is to be streamed.
 * @param modifiedTime      The modified datetime to use for the streamed content. If <tt>null</tt> the
 *                          file's timestamp will be used.
 * @param attach            Indicates whether the content should be streamed as an attachment or not
 * @param attachFileName    Optional file name to use when attach is <code>true</code>
 * @throws IOException
 */
public void streamContent(WebScriptRequest req, 
                             WebScriptResponse res, 
                             File file, 
                             Long modifiedTime,
                             boolean attach, 
                             String attachFileName,
                             Map<String, Object> model) throws IOException
{
    if (logger.isDebugEnabled())
        logger.debug("Retrieving content from file " + file.getAbsolutePath() + " (attach: " + attach + ")");
    
    // determine mimetype from file extension
    String filePath = file.getAbsolutePath();
    String mimetype = MimetypeMap.MIMETYPE_BINARY;
    int extIndex = filePath.lastIndexOf('.');
    if (extIndex != -1)
    {
        mimetype = mimetypeService.getMimetype(filePath.substring(extIndex + 1));
    }
    
    // setup file reader and stream
    FileContentReader reader = new FileContentReader(file);
    reader.setMimetype(mimetype);
    reader.setEncoding("UTF-8");
    
    long lastModified = modifiedTime == null ? file.lastModified() : modifiedTime;
    Date lastModifiedDate = new Date(lastModified);
    
    streamContentImpl(req, res, reader, null, null, attach, lastModifiedDate, String.valueOf(lastModifiedDate.getTime()), attachFileName, model);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:42,代码来源:ContentStreamer.java


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