http-post

ByteArrayOutputStream to a FileBody

假装没事ソ 提交于 2019-12-04 21:06:47
问题 I have a Uri to an image that was either taken or selected from the Gallery that I want to load up and compress as a JPEG with 75% quality. I believe I have achieved that with the following code: ByteArrayOutputStream bos = new ByteArrayOutputStream(); Bitmap bm = BitmapFactory.decodeFile(imageUri.getPath()); bm.compress(CompressFormat.JPEG, 60, bos); Not that I have tucked it into a ByteArrayOutputStream called bos I need to then add it to a MultipartEntity in order to HTTP POST it to a

Using Android to Post XML files

笑着哭i 提交于 2019-12-04 20:38:16
EDIT : I am trying to send an xml file as a post request in Android. The server accepts text/xml. I tried creating a MultipartEntity, which has a content type of multipart/form-data. HttpClient httpClient = new DefaultHttpClient(); /* New Post Request */ HttpPost postRequest = new HttpPost(url); byte[] data = IOUtils.toByteArray(payload); /* Body of the Request */ InputStreamBody isb = new InputStreamBody(new ByteArrayInputStream(data), "uploadedFile"); MultipartEntity multipartContent = new MultipartEntity(); multipartContent.addPart("uploadedFile", isb); /* Set the Body of the Request */

Python script send image to PHP

此生再无相见时 提交于 2019-12-04 19:54:11
Good day. Can somebody help me. My task is to create an python script (client side) that send image to php (server side). NOTE: The python script is run in different raspberry pi, and the php server only receive the image via internet. Achievement: I can now send a text data from my client to server. Problem: My big problem is how can I send the image? Any comments and suggestion is very appreciated. Thank You. My Python Script: import urllib2 from urllib import urlencode # 192.168.5.149 is the ip address of server url = "http://192.168.5.149/server/server.php" data = {'test':'OK'} encoded

How to get form parameters in request filter

别等时光非礼了梦想. 提交于 2019-12-04 19:08:00
问题 I'm trying to get the form parameters of a request in a request filter: @Override public ContainerRequest filter(final ContainerRequest request) { final Form formParameters = request.getFormParameters(); //logic return request; } However, the form always seems to be empty. The HttpRequestContext.getFormParameters() documentation says: Get the form parameters of the request entity. This method will ensure that the request entity is buffered such that it may be consumed by the applicaton.

Send Data Via Post Android to PHP

空扰寡人 提交于 2019-12-04 18:53:50
So, i'm trying to send message via Post in Android to PHP here is the Android Java Function: //enviando para o backend private void SendtoPHP(String reg) throws IOException { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://bubbledev.com.br/gcm/getdevice.php"); try{ List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("regid", "" + reg )); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); } catch (ClientProtocolException e) { //

Can't set HttpWebRequest timeout higher than 100 seconds when doing a POST?

徘徊边缘 提交于 2019-12-04 18:36:08
问题 I am running into an issue where HttpWebRequest won't respect a timeout value higher than 100 seconds when doing a POST. However, if the request is a GET, a timeout value higher than 100 seconds is respected. The timeout exception is thrown at the .GetResponse() call. I'm setting all the timeout values I have been able to discover but it seems I am missing one, or there is a bug in the framework. This is a C# app targeting the .NET Framework 3.5, built using Visual Studio 2008. The web server

Send image(jpg) via HttpPost from Android to Servlet(WebServer)

ⅰ亾dé卋堺 提交于 2019-12-04 18:34:35
I have an image sitting on my SDcard (of type jpg) and I am trying to send the image via HttpPost to my servlet running on Apache Tomcat 7.0 So far I have google-ing the way to do this but I can't seem to find the perfect way. Do any of you might have some suggestion or solution to this problem? Thank you in advance, Sammy Stevan Djap HttpClient is the class to use and there's a tutorial for it. See the section Using HTTP client , right after the pictures. UPDATE What follows is commentary on the tutorial example from Developerlife.com . A good thing about that example is that it demonstrates

Upload image to server with iOS not working

杀马特。学长 韩版系。学妹 提交于 2019-12-04 18:21:18
I am trying to upload an image to my php server but it's not working. When I try to upload the file, the screen just freezes (this is expected - I'm using sendSynchronousRequest until I can get this to work) for about a minute and then it returns an empty string as a response. I've been working on this for over a day and can't seem to get it to work. Furthermore, the image never actually uploads to the server (I checked). Thanks in advance! // Uploading the image -(IBAction)uploadImage:(id)sender{ [self uploadImage:UIImageJPEGRepresentation(productImageView.image, 90) filename:@"image.jpg"]; }

Send Post request to an external API using AWS Lambda in python

↘锁芯ラ 提交于 2019-12-04 17:12:07
I want to send a post request to an external API ( https://example.com/api/jobs/test ) every hour. The Lambda Function that I used is as follows: Handler: index.lambda_handler python: 3.6 index.py import requests def lambda_handler(event, context): url="https://example.com/api/jobs/test" response = requests.post(url) print(response.text) #TEXT/HTML print(response.status_code, response.reason) #HTTP Test Event: { "url": "https://example.com/api/jobs/test" } Error: START RequestId: 370eecb5-bfda-11e7-a2ed-373c1a03c17d Version: $LATEST Unable to import module 'index': No module named 'requests'

POST request on arduino with ESP8266 using WifiESP library

随声附和 提交于 2019-12-04 16:58:33
I am attempting to make RESTful POST request using the WifiESP library ( https://github.com/bportaluri/WiFiEsp ). I'm able to successfully make the request with curl, but consistently get an error using the Arduino and ESP. I suspect the problem is related to the manual formatting of the POST request the library requires, but I don't see anything wrong. Here my sanitized code: if (client.connect(server, 80)) { Serial.println("Connected to server"); // Make a HTTP request String content = "{'JSON_key': 2.5}"; // some arbitrary JSON client.println("POST /some/uri HTTP/1.1"); client.println("Host