|
@@ -12,14 +12,21 @@ import com.example.nngkxxdp.util.RedisUtil;
|
|
|
import com.example.nngkxxdp.util.SendUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.core.io.ByteArrayResource;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.URL;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import static jdk.nashorn.internal.objects.NativeError.getFileName;
|
|
|
+import static org.apache.poi.util.IOUtils.toByteArray;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequestMapping("mini/hlw")
|
|
|
@CrossOrigin
|
|
@@ -111,4 +118,25 @@ public class HLWIntefaceController {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/forward")
|
|
|
+ public ResponseEntity<Resource> forward(@RequestParam(name = "url", required = true) String url){
|
|
|
+ System.out.println("Start: ------------------------->");
|
|
|
+
|
|
|
+ Resource resource = null;
|
|
|
+ url = "http://23.99.193.13/"+url;
|
|
|
+ InputStream inputStream;
|
|
|
+ try {
|
|
|
+ inputStream = new URL(url).openStream();
|
|
|
+
|
|
|
+ resource = (Resource) new ByteArrayResource(toByteArray(inputStream));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return ResponseEntity.ok()
|
|
|
+ .contentType(MediaType.IMAGE_PNG)
|
|
|
+ .header(HttpHeaders.CONTENT_DISPOSITION, " filename=\"" + getFileName(url) + "\"")
|
|
|
+ .body(resource);
|
|
|
+ }
|
|
|
}
|