1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| public class IMinioClient extends MinioClient { private String publicBaseUrl; public void setPublicBaseUrl(String publicBaseUrl) { this.publicBaseUrl = publicBaseUrl; } protected IMinioClient(MinioClient client) { super(client); }
public String getPresignedObjectPublicUrl(GetPresignedObjectUrlArgs args) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException { return getPresignedObjectUrl(args, publicBaseUrl); }
public String getPresignedObjectUrl(GetPresignedObjectUrlArgs args, String endpoint) throws ErrorResponseException, InsufficientDataException, InternalException, InvalidKeyException, InvalidResponseException, IOException, NoSuchAlgorithmException, XmlParserException, ServerException { checkArgs(args); byte[] body = (args.method() == Method.PUT || args.method() == Method.POST) ? EMPTY_BODY : null; Multimap<String, String> queryParams = newMultimap(args.extraQueryParams()); if (args.versionId() != null) { queryParams.put("versionId", args.versionId()); } String region = getRegion(args.bucket(), args.region()); if (provider == null) { HttpUrl url = buildUrl(args.method(), args.bucket(), args.object(), region, queryParams); return url.toString(); } Credentials creds = provider.fetch(); if (creds.sessionToken() != null) { queryParams.put("X-Amz-Security-Token", creds.sessionToken()); } HttpUrl url = buildUrl(args.method(), args.bucket(), args.object(), region, queryParams); if (endpoint != null){ url = url.newBuilder(url.toString().replace(baseUrl.toString(), endpoint)).build(); } Request request = createRequest( url, args.method(), args.extraHeaders() == null ? null : httpHeaders(args.extraHeaders()), body, 0, creds); url = Signer.presignV4(request, region, creds.accessKey(), creds.secretKey(), args.expiry()); return url.toString(); } }
|