aliyun/aliyun-oss-java-sdk

getSymlink对历史版本的支持

shikaiwei1 opened this issue · 2 comments

当前版本中,getSymlink方法即使通过GenericRequest传入versionId参数,在请求时也不会带上该参数。导致无法获取到历史版本的软链接信息;
同时,我这边通过手动拼接参数,调用时带上versionId直接访问API,证实是可以返回正确的历史版本软链接的信息(“x-oss-symlink-target”)。是否可以在SDK中添加相应支持?

附上手动调用可以正常返回symlink-target信息的代码:

    public static String getSymlinkVersionTarget(
            String bucketName, String symlink, String versionId, String endpoint,
            AliyunAccountConfigEntity accountConfigEntity) throws IOException {
        RequestSigner signer = createSigner(bucketName, symlink, accountConfigEntity);
        RequestMessage requestMessage = new RequestMessage(
                bucketName, symlink
        );
        // Headers
        requestMessage.getHeaders().put(OSSHeaders.DATE, DateUtil.formatRfc822Date(new Date()));
        requestMessage.addParameter(RequestParameters.SUBRESOURCE_VRESION_ID, versionId);
        requestMessage.addParameter(RequestParameters.SUBRESOURCE_SYMLINK, null);
        signer.sign(requestMessage);
        //使用okhttp进行访问
        OkHttpClient client = new OkHttpClient.Builder().build();
        // 创建Request对象
        Request request = new Request.Builder()
                .url(new DefaultUriBuilderFactory().builder()
                        .host(String.format("%s.%s", bucketName, endpoint))
                        .scheme("https")
                        .path(symlink)
                        .queryParam(RequestParameters.SUBRESOURCE_VRESION_ID, versionId)
                        .queryParam(RequestParameters.SUBRESOURCE_SYMLINK, Collections.emptyList())
                        .build().toASCIIString())
                .headers(Headers.of(requestMessage.getHeaders()))
                .build();
        Response response = client.newCall(request).execute();
        return HttpUtil.urlDecode(response.headers().get(OSSHeaders.OSS_HEADER_SYMLINK_TARGET), "UTF-8");
    }