Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add Canonicalized_Extension_Headers for signedURL builder #2000

Copy link
Copy link

Description

@salrashid123
Issue body actions

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 
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.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.‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.