|
|
@@ -2,12 +2,9 @@ package com.github.microservice.auth.server.core.helper;
|
|
|
|
|
|
import com.github.microservice.core.util.JsonUtil;
|
|
|
import lombok.SneakyThrows;
|
|
|
-import org.apache.tomcat.util.digester.DocumentProperties;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.StreamUtils;
|
|
|
-import redis.clients.jedis.Jedis;
|
|
|
-import redis.clients.jedis.util.Pool;
|
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.InputStream;
|
|
|
@@ -16,7 +13,6 @@ import java.net.http.HttpClient;
|
|
|
import java.net.http.HttpRequest;
|
|
|
import java.net.http.HttpResponse;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
@@ -26,9 +22,6 @@ public class FaceHelper {
|
|
|
@Value("${deepface.url}")
|
|
|
private String url;
|
|
|
|
|
|
-// @Value("${deepface.detectorBackend}")
|
|
|
-// private String detectorBackend;
|
|
|
-
|
|
|
@SneakyThrows
|
|
|
public HttpResponse<String> uploadFs(InputStream inputStream, String key){
|
|
|
|
|
|
@@ -52,12 +45,7 @@ public class FaceHelper {
|
|
|
.build();
|
|
|
|
|
|
// Send the request and get the response
|
|
|
- HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
-
|
|
|
- // Print the response
|
|
|
- System.out.println("Response Code: " + response.statusCode());
|
|
|
- System.out.println("Response Body: " + response.body());
|
|
|
- return response;
|
|
|
+ return client.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
}
|
|
|
|
|
|
@SneakyThrows
|
|
|
@@ -83,12 +71,7 @@ public class FaceHelper {
|
|
|
.build();
|
|
|
|
|
|
// Send the request and get the response
|
|
|
- HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
-
|
|
|
- // Print the response
|
|
|
- System.out.println("Response Code: " + response.statusCode());
|
|
|
- System.out.println("Response Body: " + response.body());
|
|
|
- return response;
|
|
|
+ return client.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
}
|
|
|
|
|
|
@SneakyThrows
|
|
|
@@ -103,11 +86,7 @@ public class FaceHelper {
|
|
|
.POST(HttpRequest.BodyPublishers.ofByteArray(data.getBytes(StandardCharsets.UTF_8)))
|
|
|
.build();
|
|
|
// Send the request and get the response
|
|
|
- HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
- // Print the response
|
|
|
- System.out.println("Response Code: " + response.statusCode());
|
|
|
- System.out.println("Response Body: " + response.body());
|
|
|
- return response;
|
|
|
+ return client.send(request, HttpResponse.BodyHandlers.ofString());
|
|
|
}
|
|
|
|
|
|
private static byte[] buildMultipartBody(String boundary, Map<String, Object> formData) throws Exception {
|
|
|
@@ -125,11 +104,6 @@ public class FaceHelper {
|
|
|
outputStream.write(("Content-Disposition: form-data; name=\"" + key + "\"; filename=\"uploaded_file\"\r\n").getBytes(StandardCharsets.UTF_8));
|
|
|
outputStream.write("Content-Type: application/octet-stream\r\n\r\n".getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
-// byte[] buffer = new byte[8192];
|
|
|
-// int bytesRead;
|
|
|
-// while ((bytesRead = inputStream.read(buffer)) != -1) {
|
|
|
-// outputStream.write(buffer, bytesRead);
|
|
|
-// }
|
|
|
StreamUtils.copy(inputStream,outputStream);
|
|
|
|
|
|
outputStream.write("\r\n".getBytes(StandardCharsets.UTF_8));
|