我正在尝试使用 Docker Http V2 API 在此链接之后推送图像;https://docs.docker.com/registry/spec/api/#pushing-an-image;在 POST 到 /blob/uploads 后,我可以获得“Location”标头值,但块/整体上传不起作用 - 找不到 404 - 即使我正在设置所需的标头。
String url = String.format("https://%s/v2/%s/blobs/uploads/", dockerRegistry, repository);
Mono<ClientResponse> clientResponse = WebClient.create(url).post().header("Connection", "close").exchange();
ClientResponse clientResponse2 = clientResponse.block();
HttpHeaders asHttpHeaders = clientResponse2.headers().asHttpHeaders();
String location = asHttpHeaders.get("Location").get(0);
String uploadUrl = ("https://" + dockerRegistry + location);
Mono<ClientResponse> clientResponse3 =
WebClient.create(uploadUrl).patch().contentLength(bytes.length)
.header("Content-Range", "0-" + Integer.toString(bytes.length - 1))
.contentType(MediaType.APPLICATION_OCTET_STREAM).header("Connection", "close")
.bodyValue(bytes).exchange()
.timeout(Duration.ofHours(1));
ClientResponse clientResponse4 = clientResponse3.block(); // 404 NOT FOUND
HttpHeaders asHttpHeaders = clientResponse4.headers().asHttpHeaders();
return asHttpHeaders.get("Location").get(0);
我认为这里没有太大的失败空间,但我仍然收到错误消息。有人可以在这里帮助我吗?顺便说一句,我正在尝试在这里连接到 Azure Container Registry。