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

Add Canonicalized_Extension_Headers for signedURL builder #2000

Closed
salrashid123 opened this issue Apr 26, 2017 · 3 comments
Closed

Add Canonicalized_Extension_Headers for signedURL builder #2000

salrashid123 opened this issue Apr 26, 2017 · 3 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@salrashid123
Copy link

Cloud Storage SignedURLs allows for custom headers you can set to define metadata:

It doesn't look like you can add this in now during signURL construction:

note BlobInfo has metadata defined in it already so maybe use that:

the following shows how to manually construct the signed URL with canonical headers outside of this library

ServiceAccountCredentials creds = ServiceAccountCredentials.fromStream(new FileInputStream("YOUR_CERT.json")); 

String BUCKET_NAME = "your_bucket"; 
String OBJECT_NAME = "a.txt"; 
String SERVICE_ACCOUNT_EMAIL = "svc-2-429@your_project.iam.gserviceaccount.com"; 
String verb = "PUT"; 
long expiration = System.currentTimeMillis()/1000 + 60; 
String Canonicalized_Extension_Headers = "x-goog-meta-icecreamflavor:vanilla"; 


byte[] sr = creds.sign( (verb + "\n\n\n" + expiration + "\n" + Canonicalized_Extension_Headers + 
"\n" + "/" + BUCKET_NAME + "/" + OBJECT_NAME ).getBytes() ); 
String url_signature = new String(Base64.encodeBase64( sr )); 
String signed_url = "https://storage.googleapis.com/" + BUCKET_NAME + "/" + OBJECT_NAME + 
"?GoogleAccessId=" + SERVICE_ACCOUNT_EMAIL + 
"&Expires=" + expiration + 
"&Signature=" + URLEncoder.encode(url_signature, "UTF-8"); 

System.out.println(signed_url); 

Just to note, you'll need to post the headers too but thats outside of this FR:

curl -v -H "x-goog-meta-icecreamflavor:vanilla" -X PUT "https://storage.googleapis.com/.....&Signature=Ol1zLbXd0W%2B3q....3D%3D" --upload-file a.txt 
@shinfan shinfan added api: storage Issues related to the Cloud Storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. labels May 8, 2017
@frantello
Copy link

Kindly see pull request #2422

@yihanzhen
Copy link
Contributor

This has been added to our feature backlog: https://github.com/GoogleCloudPlatform/google-cloud-java/wiki/Feature-backlog . This issue will be closed but is linked in the backlog and can continue to be used for comment and discussion.

@yihanzhen
Copy link
Contributor

This feature request is finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

4 participants