A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Code Examples of MultipartEntity


        }
        HttpClient client = new DefaultHttpClient();
        // Should it be HTTP/1.1?
        //  client.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
        HttpPost post = new HttpPost(Monac.GATEWAY_URL + PATH_MESSAGE_RECEIVER);
        MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        
        JSONArray mess = new JSONArray();
        // reverse order.
        for (int i = missings.length() - 1; i >= 0; i--) {
            String mid = null;
            try {
                mid = missings.getString(i);
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Message mes = null;
            if (mid != null) {
                mes = mdb.fetchMessage(mid);
            }
            if (mes != null) { 
                mess.put(mes.getJSONObject());
            }
        }
        try {
            try {
                entity.addPart("messages", new StringBody(mess.toString(), "text/plain",
                        Charset.forName("UTF-8")));
            } catch (IllegalCharsetNameException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (UnsupportedCharsetException e) {

View Full Code Here


	 */ 
	private JSONObject sendTextRequest()
	{		
	    // Prepare a multipart HTTP POST request
		HttpPost Request             = new HttpPost(BASE_URL);
		MultipartEntity Entity       = new MultipartEntity();
		File Recording               = new File(m_AudioPath);
		Map<String, Object> PostData = new HashMap<String, Object>();
		
		// Set the parameters to send to eso.terik.us
		PostData.put(MAX_FILE_SIZE_PARAM, MAX_FILE_SIZE);
		PostData.put(CELL_PARAM, m_LocalCellNumber);
		PostData.put(INPUT_PARAM, Recording);
		
		try
		{
		    // Add multipart data to POST request
			for (String Parameter : PostData.keySet())
			{
			    if (PostData.get(Parameter) instanceof File)
				{
			    	Entity.addPart(Parameter, new FileBody((File) PostData.get(Parameter)));
			    }
				else
				{
					Entity.addPart(Parameter, new StringBody("" + PostData.get(Parameter)));
			    }
			}
		}
		catch (UnsupportedEncodingException e)
		{

View Full Code Here


    
	public String post(String RemoteURI, HashMap<String, Object> PostData)
    {        
        // Prepare a (possibly multipart) HTTP POST request
        HttpPost Request       = new HttpPost(RemoteURI);
        MultipartEntity Entity = new MultipartEntity();
        
        try
        {
            // Add multipart data to POST request
            for (String Parameter : PostData.keySet())
            {
                if (PostData.get(Parameter) instanceof File)
                {
                    Entity.addPart(Parameter, new FileBody((File) PostData.get(Parameter)));
                }
                else if (PostData.get(Parameter) instanceof String)
                {
                    Entity.addPart(Parameter, new StringBody(URLEncoder.encode((String) PostData.get(Parameter))));
                }
                else
                {
                    Log.w(LOCAL_TAG, "Unsupported data type at " + Parameter);
                }

View Full Code Here


		{
			DefaultHttpClient httpclient = new DefaultHttpClient();
			File f = new File(fileName);

			HttpPost httpost = new HttpPost("http://local.geotracing.com/tland/media.srv");
			MultipartEntity entity = new MultipartEntity();
			entity.addPart("myIdentifier", new StringBody("somevalue"));
			entity.addPart("myFile", new FileBody(f));
			httpost.setEntity(entity);

			HttpResponse response;

			response = httpclient.execute(httpost);

			Log.d(LOG_TAG, "Upload result: " + response.getStatusLine());

			if (entity != null)
			{
				entity.consumeContent();
			}

			httpclient.getConnectionManager().shutdown();

		} catch (Throwable ex)

View Full Code Here


			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		// ??????
		MultipartEntity entity = new MultipartEntity(HttpMultipartMode.STRICT,
				null, Charset.forName("UTF-8"));
		File file = new File(imageUri);
		Log.v("File ", "exit" + file.exists());
		FileBody cbFile = new FileBody(file, "image/jpeg");
		try {
			// ??????
			// ContentBody cbString = new
			// StringBody(Constant.consumerKey,Charset.forName("UTF-8"));
			// entity.addPart(URLEncoder.encode("source","UTF-8"), cbString);
			entity.addPart("image", cbFile);
			post.setEntity(entity);
			// ????post???????HttpResponse
			HttpClient hc = new DefaultHttpClient();
			HttpResponse rp = null;
			rp = hc.execute(post);

View Full Code Here


			
			// generate a post action
			HttpPost httpPost = new HttpPost( this.serviceUrl );
			
			// get multipart entity
			MultipartEntity entity = new MultipartEntity();
			
			// add the input params as parts of input
			entity.addPart("token", new StringBody( this.uploadToken ) );
			entity.addPart("title", new StringBody( title ) );
			entity.addPart("author", new StringBody( author) );
			// add file
			entity.addPart("file_upload", new FileBody(file) );
			
			httpPost.setEntity( entity );
			
			HttpResponse response = httpClient.execute( httpPost );
		

View Full Code Here


    public static Test suite() {
        return new TestSuite(TestMultipartFormHttpEntity.class);
    }

    public void testExplictContractorParams() throws Exception {
        MultipartEntity entity = new MultipartEntity(
                HttpMultipartMode.BROWSER_COMPATIBLE,
                "whatever",
                CharsetUtil.getCharset("UTF-8"));

        assertNull(entity.getContentEncoding());
        assertNotNull(entity.getContentType());
        Header header = entity.getContentType();
        HeaderElement[] elems = header.getElements();
        assertNotNull(elems);
        assertEquals(1, elems.length);

        HeaderElement elem = elems[0];

View Full Code Here


        mFacebookMethodFactory.unsetSession();
    }
    
    private MultipartEntity makeMultipartEntityFromParameters(FBMethod method, ByteArrayBody.WriteToProgressHandler runnable)
            throws UnsupportedEncodingException {
        MultipartEntity multipartEntity = new MultipartEntity();
        for (String key : method.mParameters.keySet()) {
            multipartEntity.addPart(key, new StringBody(method.mParameters.get(key)));
        }
        multipartEntity.addPart("data", new ByteArrayBody(method.mData, method.mDataFilename, runnable));
        return multipartEntity;
    }
}

View Full Code Here


                "/servlets-examples/servlet/RequestInfoExample");

        FileBody bin = new FileBody(new File(args[0]));
        StringBody comment = new StringBody("A binary file of some kind");

        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("bin", bin);
        reqEntity.addPart("comment", comment);
        
        httppost.setEntity(reqEntity);
        
        System.out.println("executing request " + httppost.getRequestLine());
        HttpResponse response = httpclient.execute(httppost);

View Full Code Here


                "/servlets-examples/servlet/RequestInfoExample");

        FileBody bin = new FileBody(new File(args[0]));
        StringBody comment = new StringBody("A binary file of some kind");

        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("bin", bin);
        reqEntity.addPart("comment", comment);
        
        httppost.setEntity(reqEntity);
        
        System.out.println("executing request " + httppost.getRequestLine());
        HttpResponse response = httpclient.execute(httppost);

View Full Code Here


            // seems pretty decent for
            // quality + size.
            Log.e("app engine remote eyes", "upload starting");
            HttpPost httpPost = new HttpPost(postUrl);
            Log.e("app engine perf", "0");
            MultipartEntity entity = new MultipartEntity();
            Log.e("app engine perf", "1");
            entity.addPart("img",
                    new InputStreamBody(new ByteArrayInputStream(out.toByteArray()), "video.jpg"));
            Log.e("app engine perf", "2");
            httpPost.setEntity(entity);
            Log.e("app engine perf", "3");
            HttpResponse response = httpclient.execute(httpPost);

View Full Code Here


            // seems pretty decent for
            // quality + size.
            Log.e("app engine remote eyes", "upload starting");
            HttpPost httpPost = new HttpPost(postUrl);
            Log.e("app engine perf", "0");
            MultipartEntity entity = new MultipartEntity();
            Log.e("app engine perf", "1");
            entity.addPart("img",
                    new InputStreamBody(new ByteArrayInputStream(out.toByteArray()), "video.jpg"));
            Log.e("app engine perf", "2");
            httpPost.setEntity(entity);
            Log.e("app engine perf", "3");
            HttpResponse response = httpclient.execute(httpPost);

View Full Code Here


                "/servlets-examples/servlet/RequestInfoExample");

        FileBody bin = new FileBody(new File(args[0]));
        StringBody comment = new StringBody("A binary file of some kind");

        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("bin", bin);
        reqEntity.addPart("comment", comment);
        
        httppost.setEntity(reqEntity);
        
        System.out.println("executing request " + httppost.getRequestLine());
        HttpResponse response = httpclient.execute(httppost);

View Full Code Here


			httpClient.getParams().setParameter("http.socket.timeout", new Integer(90000)); // 90 second
			post = new HttpPost(new URI(UPLOAD_URL));
			post.setHeader("User-Agent", "Mozilla /4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.6) Vodafone/1.0/SFR_v1615/1.56.163.8.39");
			File file = new File(filepath);
			
			MultipartEntity multipart = new MultipartEntity();
		    ContentBody cbFile = new FileBody(file, "image/jpeg");
		    multipart.addPart("fichier", cbFile);

		    post.setEntity(multipart);

			HttpResponse response = httpClient.execute(post);
			Log.d(LOG_TAG, "Response Status line code:" + response.getStatusLine().getStatusCode());

View Full Code Here


					final HttpClient httpClient = new DefaultHttpClient();

					final HttpPost request = new HttpPost(UPLOADSCRIPT_URL);

					// create the multipart request and add the parts to it
					final MultipartEntity requestEntity = new MultipartEntity();
					requestEntity.addPart("gpxfile", new InputStreamBody(gpxInputStream, ""
							+ System.currentTimeMillis() + ".gpx"));

					httpClient.getParams().setBooleanParameter("http.protocol.expect-continue",
							false);

View Full Code Here


					final HttpClient httpClient = new DefaultHttpClient();

					final HttpPost request = new HttpPost(UPLOADSCRIPT_URL);

					// create the multipart request and add the parts to it
					final MultipartEntity requestEntity = new MultipartEntity();
					requestEntity.addPart("gpxfile", new InputStreamBody(gpxInputStream, ""
							+ System.currentTimeMillis() + ".gpx"));

					httpClient.getParams().setBooleanParameter("http.protocol.expect-continue",
							false);

View Full Code Here


					final HttpClient httpClient = new DefaultHttpClient();
	
					final HttpPost request = new HttpPost(UPLOADSCRIPT_URL);
	
					// create the multipart request and add the parts to it
					final MultipartEntity requestEntity = new MultipartEntity();
					requestEntity.addPart("gpxfile", new InputStreamBody(gpxInputStream, "" + System.currentTimeMillis() + ".gpx"));
	
					httpClient.getParams().setBooleanParameter("http.protocol.expect-continue", false);
	
					request.setEntity(requestEntity);
	

View Full Code Here

TOP

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

TOP