public sealed class UrlSigner.RequestTemplate
Reference documentation and code samples for the Google Cloud Storage v1 API class UrlSigner.RequestTemplate.
Represents the request template to be signed.
Namespace
Google.Cloud.Storage.V1Assembly
Google.Cloud.Storage.V1.dll
Remarks
When either of the headers collections are specified, there are certain headers which will be included in the signed URL's signature, and therefore must be included in requests made with the created URL. These are the Content-MD5 and Content-Type content headers as well as any content or request header with a name starting with "x-goog-".
If the headers collections are null or empty, no headers are included in the signed URL's signature, so any requests made with the created URL must not contain Content-MD5, Content-Type, or any header starting with "x-goog-".
Note that when GET is specified as the HttpMethod (or it is null, in which case GET is used), both GET and HEAD requests can be made with the created signed URL.
Properties
Bucket
public string Bucket { get; }
The name of the bucket. This will never be null.
Property Value | |
---|---|
Type | Description |
string |
ContentHeaders
public IReadOnlyDictionary<string, IReadOnlyCollection<string>> ContentHeaders { get; }
The headers for the content which will be included with the request. This will never be null. If null is specified in WithContentHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>>) then an empty dictionary will be used.
Property Value | |
---|---|
Type | Description |
IReadOnlyDictionarystringIReadOnlyCollectionstring |
When using V2, from all the headers supplied in ContentHeaders, only the ones starting with "x-goog-", the Content-MD5 and the Content-Type headers will be included in the signed URL's signature and therefor must be included in requests made with the created URL. All other headers supplied in ContentHeaders will be ignored when creating the signed URL so they shouldn't be included in requests made with the created URL.
When using V4 all headers supplied in ContentHeaders will be included in the signed URL's signature and therefor must be included in requests made with the created URL.
HttpMethod
public HttpMethod HttpMethod { get; }
The HTTP request method for which the signed URL is allowed to be used. This will never be null. If null is specified in WithHttpMethod(HttpMethod) then this value will be set to Get. Will default to Get.
Property Value | |
---|---|
Type | Description |
HttpMethod |
Note that when GET is specified as the HttpMethod, both GET and HEAD requests can be made with the created signed URL.
ObjectName
public string ObjectName { get; }
The name of the object within the bucket. May be null, in which case the signed URL will refer to the bucket instead of an object.
Property Value | |
---|---|
Type | Description |
string |
QueryParameters
public IReadOnlyDictionary<string, IReadOnlyCollection<string>> QueryParameters { get; }
The query parameters which will be included with the request. This will never be null. If null is specified in WithQueryParameters(IEnumerable<KeyValuePair<string, IEnumerable<string>>>) then an empty dictionary will be used.
Property Value | |
---|---|
Type | Description |
IReadOnlyDictionarystringIReadOnlyCollectionstring |
When using V2 custom query parameters are not supported by the signing process and Sign(RequestTemplate, Options) and SignAsync(RequestTemplate, Options, CancellationToken) will throw ArgumentException if QueryParameters is not an empty dictionary, that is, if one or more custom query parameters have been specified.
RequestHeaders
public IReadOnlyDictionary<string, IReadOnlyCollection<string>> RequestHeaders { get; }
The headers which will be included with the request. This will never be null. If null is specified in WithRequestHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>>) then an empty dictionary will be used.
Property Value | |
---|---|
Type | Description |
IReadOnlyDictionarystringIReadOnlyCollectionstring |
When using V2, from all the headers supplied in RequestHeaders, only the ones starting with "x-goog-" will be included in the signed URL's signature and therefor must be included in requests made with the created URL. All other headers supplied in RequestHeaders will be ignored when creating the signed URL so they shouldn't be included in requests made with the created URL.
When using V4 all headers supplied in RequestHeaders will be included in the signed URL's signature and therefor must be included in requests made with the created URL.Note that if the entity is encrypted with customer-supplied encryption keys (see https://cloud.google.com/storage/docs/encryption for more information), the x-goog-encryption-algorithm, x-goog-encryption-key, and x-goog-encryption-key-sha256 headers will be required when making the request. However, only the x-goog-encryption-algorithm header is included in the signature for the signed URL. So the RequestHeaders specified only need to have the x-goog-encryption-algorithm header.
Methods
FromBucket(string)
public static UrlSigner.RequestTemplate FromBucket(string bucket)
Creates a new request template to sign from the given bucket name.
Parameter | |
---|---|
Name | Description |
bucket | string The name of the bucket for which the signed URL will be created. Must not be null. |
Returns | |
---|---|
Type | Description |
UrlSignerRequestTemplate | A new request template. |
WithBucket(string)
public UrlSigner.RequestTemplate WithBucket(string bucket)
Returns a new request template with all the same settings as this one except for the bucket name.
Parameter | |
---|---|
Name | Description |
bucket | string The new bucket name. Must not be null. |
Returns | |
---|---|
Type | Description |
UrlSignerRequestTemplate | A new request template. |
WithContentHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>>)
public UrlSigner.RequestTemplate WithContentHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>> contentHeaders)
Returns a new request template with all the same settings as this one except for the content headers.
Parameter | |
---|---|
Name | Description |
contentHeaders | IEnumerableKeyValuePairstringIEnumerablestring The new content headers. May be null, in which case an empty collection will be used. |
Returns | |
---|---|
Type | Description |
UrlSignerRequestTemplate | A new request template. |
WithHttpMethod(HttpMethod)
public UrlSigner.RequestTemplate WithHttpMethod(HttpMethod method)
Returns a new request template with all the same settings as this one except for the HTTP method.
Parameter | |
---|---|
Name | Description |
method | HttpMethod The new HTTP method. May be null, in which case Get will be used. |
Returns | |
---|---|
Type | Description |
UrlSignerRequestTemplate | A new request template. |
WithHttpRequestMessage(HttpRequestMessage)
public UrlSigner.RequestTemplate WithHttpRequestMessage(HttpRequestMessage requestMessage)
Returns a new request template with all the same settings as this one
except for all the information that can be obtained from requestMessage
,
that is the HTTP method, the request headers and the content headers.
Parameter | |
---|---|
Name | Description |
requestMessage | HttpRequestMessage The new request message. May be null, in which case the default values for all the affected properties will be used.. |
Returns | |
---|---|
Type | Description |
UrlSignerRequestTemplate | A new request template. |
WithObjectName(string)
public UrlSigner.RequestTemplate WithObjectName(string objectName)
Returns a new request template with all the same settings as this one except for the object name.
Parameter | |
---|---|
Name | Description |
objectName | string The new object name. May be null, in which case the signed URL will refer to the bucket instead of an object. |
Returns | |
---|---|
Type | Description |
UrlSignerRequestTemplate | A new request template. |
WithQueryParameters(IEnumerable<KeyValuePair<string, IEnumerable<string>>>)
public UrlSigner.RequestTemplate WithQueryParameters(IEnumerable<KeyValuePair<string, IEnumerable<string>>> queryParameters)
Returns a new request template with all the same settings as this one except for the query parameters.
Parameter | |
---|---|
Name | Description |
queryParameters | IEnumerableKeyValuePairstringIEnumerablestring The new query parameters. May be null, in which case an empty collection will be used. |
Returns | |
---|---|
Type | Description |
UrlSignerRequestTemplate | A new request template. |
WithRequestHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>>)
public UrlSigner.RequestTemplate WithRequestHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>> requestHeaders)
Returns a new request template with all the same settings as this one except for the request headers.
Parameter | |
---|---|
Name | Description |
requestHeaders | IEnumerableKeyValuePairstringIEnumerablestring The new request headers. May be null, in which case an empty collection will be used. |
Returns | |
---|---|
Type | Description |
UrlSignerRequestTemplate | A new request template. |