HTTP 请求。如何获取png名称? Spring 开机

Http Request. How to get png name? Spring Boot

我有一个网络应用程序。我在 /src/main/resources/static/images/Head.png.

中有一个 png 文件

我想向它发出 http 请求以获取此 png 文件 (localhost:8080/images/Head.png)。

ResponseEntity<byte[]> entity = new TestRestTemplate().getForEntity("http://localhost/images/Head.png", byte[].class);

而且我想知道这个 png 文件的名称是什么。

我正在尝试使用一些代码,但它不起作用。

例如,使用 entity.getHeaders().toString() 我得到:

Server=[Apache-Coyote/1.1], Last-Modified=[Mon, 28 Sep 2015 22:03:31 GMT], Content-Type=[image/png;charset=UTF-8], Content-Length=[442526], Date=[Tue, 29 Sep 2015 21:02:11 GMT]

但是没有name文件的信息

我怎样才能得到这个名字文件?你可以查看我的代码 here.

谢谢

您无法获取文件名,除非您将其作为附加参数传递或在原始上传中 header 传递。 HTTP 不知道也不关心文件系统以及与它们相关的任何东西。