diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java index 914b571ba6..27e626264b 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java @@ -764,14 +764,14 @@ public WriteChannel writer(BlobWriteOption... options) { * * *

Example of creating a signed URL for the blob that is valid for 2 weeks, using the default - * credentials for signing the URL. + * credentials for signing the URL: * *

{@code
    * URL signedUrl = blob.signUrl(14, TimeUnit.DAYS);
    * }
* *

Example of creating a signed URL for the blob passing the {@link - * SignUrlOption#signWith(ServiceAccountSigner)} option, that will be used to sign the URL. + * SignUrlOption#signWith(ServiceAccountSigner)} option, that will be used to sign the URL: * *

{@code
    * String keyPath = "/path/to/key.json";
@@ -779,6 +779,13 @@ public WriteChannel writer(BlobWriteOption... options) {
    *     ServiceAccountCredentials.fromStream(new FileInputStream(keyPath))));
    * }
* + *

Example of creating a signed URL for a blob generation: + * + *

{@code
+   * URL signedUrl = blob.signUrl(1, TimeUnit.HOURS,
+   *     SignUrlOption.withQueryParams(ImmutableMap.of("generation", "1576656755290328")));
+   * }
+ * * @param duration time until the signed URL expires, expressed in {@code unit}. The finer * granularity supported is 1 second, finer granularities will be truncated * @param unit time unit of the {@code duration} parameter diff --git a/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java b/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java index 527848747f..6c1949f384 100644 --- a/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java +++ b/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java @@ -2483,7 +2483,7 @@ Blob create( * } * *

Example of creating a signed URL passing the {@link - * SignUrlOption#signWith(ServiceAccountSigner)} option, that will be used for signing the URL. + * SignUrlOption#signWith(ServiceAccountSigner)} option, that will be used for signing the URL: * *

{@code
    * String bucketName = "my-unique-bucket";
@@ -2498,6 +2498,19 @@ Blob create(
    * 

Note that the {@link ServiceAccountSigner} may require additional configuration to enable * URL signing. See the documentation for the implementation for more details. * + *

Example of creating a signed URL for a blob with generation: + * + *

{@code
+   * String bucketName = "my-unique-bucket";
+   * String blobName = "my-blob-name";
+   * long generation = 1576656755290328L;
+   *
+   * URL signedUrl = storage.signUrl(
+   *     BlobInfo.newBuilder(bucketName, blobName, generation).build(),
+   *     7, TimeUnit.DAYS,
+   *     SignUrlOption.withQueryParams(ImmutableMap.of("generation", String.valueOf(generation))));
+   * }
+ * * @param blobInfo the blob associated with the signed URL * @param duration time until the signed URL expires, expressed in {@code unit}. The finest * granularity supported is 1 second, finer granularities will be truncated