@@ -1142,6 +1142,39 @@ public ObjectStat statObject(String bucketName, String objectName)
11421142 }
11431143
11441144
1145+ /**
1146+ * Gets object's URL in given bucket. The URL is ONLY useful to retrieve the object's data if the object has
1147+ * public read permissions.
1148+ *
1149+ * <p><b>Example:</b>
1150+ * <pre>{@code String url = minioClient.getObjectUrl("my-bucketname", "my-objectname");
1151+ * System.out.println(url); }</pre>
1152+ *
1153+ * @param bucketName Bucket name.
1154+ * @param objectName Object name in the bucket.
1155+ *
1156+ * @return string contains URL to download the object.
1157+ *
1158+ * @throws InvalidBucketNameException upon invalid bucket name is given
1159+ * @throws NoResponseException upon no response from server
1160+ * @throws IOException upon connection error
1161+ * @throws XmlPullParserException upon parsing response xml
1162+ * @throws ErrorResponseException upon unsuccessful execution
1163+ * @throws InternalException upon internal library error
1164+ */
1165+ public String getObjectUrl (String bucketName , String objectName )
1166+ throws InvalidBucketNameException , NoSuchAlgorithmException , InsufficientDataException , IOException ,
1167+ InvalidKeyException , NoResponseException , XmlPullParserException , ErrorResponseException ,
1168+ InternalException {
1169+ updateRegionCache (bucketName );
1170+ String region = BucketRegionCache .INSTANCE .region (bucketName );
1171+
1172+ Request request = createRequest (Method .GET , bucketName , objectName , region , null , null , null , null , 0 );
1173+ HttpUrl url = request .httpUrl ();
1174+ return url .toString ();
1175+ }
1176+
1177+
11451178 /**
11461179 * Gets entire object's data as {@link InputStream} in given bucket. The InputStream must be closed
11471180 * after use else the connection will remain open.
0 commit comments