| | |
| | | String urlParameters = ""; |
| | | try { |
| | | //Create connection |
| | | URL url = new URL("http://123.207.143.213:9333/dir/assign"); |
| | | // URL url = new URL("http://123.207.143.213:9333/dir/assign"); |
| | | URL url = new URL("http://192.168.222.1:9333/dir/assign"); |
| | | connection = (HttpURLConnection) url.openConnection(); |
| | | connection.setConnectTimeout(2 * 1000); |
| | | connection.setRequestMethod("POST"); |
| | | connection.setRequestProperty("Content-Type", |
| | | "application/x-www-form-urlencoded"); |
| | |
| | | wr.close(); |
| | | //Get Response |
| | | InputStream is = connection.getInputStream(); |
| | | // String responseStr = IOUtils.toString(is); |
| | | BufferedReader rd = new BufferedReader(new InputStreamReader(is)); |
| | | StringBuilder response = new StringBuilder(); // or StringBuffer if Java version 5+ |
| | | String line; |
| | |
| | | } |
| | | rd.close(); |
| | | String responseStr = response.toString(); |
| | | is.close(); |
| | | // System.out.println("WeedUpload.upload responseStr=" + responseStr); |
| | | assignMap = gson.fromJson(responseStr, Map.class); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | //Create connection |
| | | // URL url = new URL("http://123.207.143.213:8081/"+assignMap.get("fid")); |
| | | String charset = "UTF-8"; |
| | | String requestURL = "http://123.207.143.213:8081/" + assignMap.get("fid"); |
| | | // String requestURL = "http://123.207.143.213:8081/" + assignMap.get("fid"); |
| | | String requestURL = "http://192.168.222.1:8081/" + assignMap.get("fid"); |
| | | pictureUrl = requestURL; |
| | | System.out.println("WeedUpload.upload " + requestURL); |
| | | // System.out.println("WeedUpload.upload " + requestURL + " " + FrameUtil.getFrames()); |
| | | MultipartUtilityV2 multipart = new MultipartUtilityV2(requestURL); |
| | | multipart.addFilePart("file", camera_image_path_file); |
| | | String response = multipart.finish(); // response from server. |
| | | System.out.println(response); |
| | | // System.out.println(response); |
| | | return requestURL; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | return pictureUrl; |
| | | } finally { |
| | | if (connection != null) { |
| | | connection.disconnect(); |