當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。