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


Java MultipartRequestEntity.getContentType方法代码示例

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


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

示例1: buildMultipartPostRequest

import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; //导入方法依赖的package包/类
public PostRequest buildMultipartPostRequest(File file, String filename, String siteId, String containerId) throws IOException
{
    Part[] parts = 
        { 
            new FilePart("filedata", file.getName(), file, "text/plain", null), 
            new StringPart("filename", filename),
            new StringPart("description", "description"), 
            new StringPart("siteid", siteId), 
            new StringPart("containerid", containerId) 
        };

    MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(parts, new HttpMethodParams());

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    multipartRequestEntity.writeRequest(os);

    PostRequest postReq = new PostRequest(UPLOAD_URL, os.toByteArray(), multipartRequestEntity.getContentType());
    return postReq;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:20,代码来源:UploadWebScriptTest.java

示例2: buildMultipartPostRequest

import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; //导入方法依赖的package包/类
public PostRequest buildMultipartPostRequest(File file) throws IOException
{
    Part[] parts = { new FilePart("filedata", file.getName(), file, "application/zip", null) };

    MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(parts, new HttpMethodParams());

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    multipartRequestEntity.writeRequest(os);

    PostRequest postReq = new PostRequest(UPLOAD_URL, os.toByteArray(), multipartRequestEntity.getContentType());
    return postReq;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:13,代码来源:CustomModelImportTest.java

示例3: build

import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; //导入方法依赖的package包/类
public MultiPartRequest build() throws IOException
{
    List<Part> parts = new ArrayList<>();

    if (fileData != null)
    {
        FilePart fp = new FilePart("filedata", fileData.getFileName(), fileData.getFile(), fileData.getMimetype(), null);
        // Get rid of the default values added upon FilePart instantiation
        fp.setCharSet(fileData.getEncoding());
        fp.setContentType(fileData.getMimetype());
        parts.add(fp);
        addPartIfNotNull(parts, "name", fileData.getFileName());
    }
    addPartIfNotNull(parts, "relativepath", relativePath);
    addPartIfNotNull(parts, "updatenoderef", updateNodeRef);
    addPartIfNotNull(parts, "description", description);
    addPartIfNotNull(parts, "contenttype", contentTypeQNameStr);
    addPartIfNotNull(parts, "aspects", getCommaSeparated(aspects));
    addPartIfNotNull(parts, "majorversion", majorVersion);
    addPartIfNotNull(parts, "overwrite", overwrite);
    addPartIfNotNull(parts, "autorename", autoRename);
    addPartIfNotNull(parts, "nodetype", nodeType);
    addPartIfNotNull(parts, "renditions", getCommaSeparated(renditionIds));

    if (!properties.isEmpty())
    {
        for (Entry<String, String> prop : properties.entrySet())
        {
            parts.add(new StringPart(prop.getKey(), prop.getValue()));
        }
    }

    MultipartRequestEntity req = new MultipartRequestEntity(parts.toArray(new Part[parts.size()]), new HttpMethodParams());

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    req.writeRequest(os);

    return new MultiPartRequest(os.toByteArray(), req.getContentType(), req.getContentLength());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:40,代码来源:MultiPartBuilder.java


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