Package org.apache.http.entity.mime

Examples of org.apache.http.entity.mime.HttpMultipart


            }
            //(1) setting the correct header
            String contentType = String.format("%s/%s; charset=%s; boundary=%s",
                mediaType.getType(),mediaType.getSubtype(),charset.toString(),CONTENT_ITEM_BOUNDARY);
            httpHeaders.putSingle(HttpHeaders.CONTENT_TYPE,contentType);
            HttpMultipart entity = new HttpMultipart("from-data", charset ,CONTENT_ITEM_BOUNDARY);
            //(2) serialising the metadata
            if(!isOmitMetadata(properties)){
                entity.addBodyPart(new FormBodyPart("metadata", new ClerezzaContentBody(
                    ci.getUri().getUnicodeString(), ci.getMetadata(),
                    rdfFormat)));
            }
            //(3) serialising the Content (Bloby)
            //(3.a) Filter based on parameter
            List<Entry<UriRef,Blob>> includedBlobs = filterBlobs(ci, properties);
            //(3.b) Serialise the filtered
            if(!includedBlobs.isEmpty()) {
                HttpMultipart content = new HttpMultipart("alternate", UTF8 ,"contentParts");
                for(Entry<UriRef,Blob> entry : includedBlobs){
                    content.addBodyPart(new FormBodyPart(entry.getKey().getUnicodeString(),
                        new BlobContentBody(entry.getValue()))); //no file name
                }
                //add all the blobs
                entity.addBodyPart(new FormBodyPart("content",new MultipartContentBody(content, null)));
            } //else no content to include
View Full Code Here


                "\nIt is a secret, that the city of Berlin is the capital of Germany since 1990.";
       
        //The multipart entity for the contentItem
        MultipartEntity contentItem = new MultipartEntity(null, null ,UTF8);
        //The multipart/alternate mime part for the parsed content versions
        HttpMultipart content = new HttpMultipart("alternate", UTF8 ,"contentParts");
        //add the content part to the contentItem
        contentItem.addPart(
            "content", //the name MUST BE "content"
            new MultipartContentBody(content));
        //now add the content (ordering is important, because the first
        //part will be assumed the original document and all following are
        //assumed alternate - transformed - versions
        content.addBodyPart(new FormBodyPart(
            "http://www.example.com/test.html", //the id of the content
            new StringBody(HTML_CONTENT, "text/html", UTF8)));
        content.addBodyPart(new FormBodyPart(
            "http://www.example.com/test.txt",
            new StringBody(extraTextConent, "text/plain", UTF8)));
       
        String receivedContent = executor.execute(
            builder.buildPostRequest(getEndpoint())
View Full Code Here

TOP

Related Classes of org.apache.http.entity.mime.HttpMultipart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.