Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: examples of creating a signed url for a blob with generation #140

Merged
merged 2 commits into from Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -764,21 +764,28 @@ public WriteChannel writer(BlobWriteOption... options) {
* </ol>
*
* <p>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:
*
* <pre>{@code
* URL signedUrl = blob.signUrl(14, TimeUnit.DAYS);
* }</pre>
*
* <p>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:
*
* <pre>{@code
* String keyPath = "/path/to/key.json";
* URL signedUrl = blob.signUrl(14, TimeUnit.DAYS, SignUrlOption.signWith(
* ServiceAccountCredentials.fromStream(new FileInputStream(keyPath))));
* }</pre>
*
* <p>Example of creating a signed URL for a blob generation:
*
* <pre>{@code
* URL signedUrl = blob.signUrl(1, TimeUnit.HOURS,
* SignUrlOption.withQueryParams(ImmutableMap.of("generation", "1576656755290328")));
* }</pre>
*
* @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
Expand Down
Expand Up @@ -2483,7 +2483,7 @@ Blob create(
* }</pre>
*
* <p>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:
*
* <pre>{@code
* String bucketName = "my-unique-bucket";
Expand All @@ -2498,6 +2498,19 @@ Blob create(
* <p>Note that the {@link ServiceAccountSigner} may require additional configuration to enable
* URL signing. See the documentation for the implementation for more details.
*
* <p>Example of creating a signed URL for a blob with generation:
*
* <pre>{@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))));
* }</pre>
*
* @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
Expand Down