a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
app/src/main/java/com/basic/security/utils/WeedUpload.java
@@ -22,8 +22,10 @@
            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");
@@ -39,6 +41,7 @@
                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;
@@ -48,6 +51,8 @@
                }
                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();
@@ -69,16 +74,18 @@
                    //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();