Google-cloud-java: Feature Request: Signed URLs for Google Cloud Storage Blobs and Buckets

Created on 12 Dec 2017  路  3Comments  路  Source: googleapis/google-cloud-java

Would it be possible to add functionality to Blob and Bucket to provide signed URLs?

We were discussing this topic (spring-cloud/spring-cloud-gcp#251) and it looks like the existing instructions on the dev site has users construct that URL themselves.

storage feature request

Most helpful comment

Hi @ChengyuanZhao -

The client library does support signed URLs for Blobs, here is a sample code for your reference:

Storage storage = StorageOptions.getDefaultInstance().getService();
String bucketName = "[BUCKET_NAME]";
String blobName = "[BLOB_NAME]";
String keyPath = "[PATH_TO_KEY]";
URL signedUrl = storage.signUrl(BlobInfo.newBuilder(bucketName, blobName).build(), 
        14, TimeUnit.DAYS, SignUrlOption.signWith(ServiceAccountCredentials.fromStream(
        new FileInputStream(keyPath))));

Signed Url for Blobs is in the works along with #2629. Please stand by.

All 3 comments

Hi @ChengyuanZhao -

The client library does support signed URLs for Blobs, here is a sample code for your reference:

Storage storage = StorageOptions.getDefaultInstance().getService();
String bucketName = "[BUCKET_NAME]";
String blobName = "[BLOB_NAME]";
String keyPath = "[PATH_TO_KEY]";
URL signedUrl = storage.signUrl(BlobInfo.newBuilder(bucketName, blobName).build(), 
        14, TimeUnit.DAYS, SignUrlOption.signWith(ServiceAccountCredentials.fromStream(
        new FileInputStream(keyPath))));

Signed Url for Blobs is in the works along with #2629. Please stand by.

Move this issue to feature backlog and close it here. This place can continue to be used for discussion.

client library does not support it for all platforms. For example, StorageClient class for .NET does not have method SignUrl.

Was this page helpful?
0 / 5 - 0 ratings