123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
-
-
-
- using System;
- using System.Collections.Generic;
- using Aliyun.OSS.Util;
- namespace Aliyun.OSS
- {
-
-
-
- public class GeneratePresignedUriRequest
- {
- private SignHttpMethod _method;
- private IDictionary<string, string> _userMetadata = new Dictionary<string, string>();
- private IDictionary<string, string> _queryParams = new Dictionary<string, string>();
- private ResponseHeaderOverrides _responseHeader = new ResponseHeaderOverrides();
-
-
-
- public SignHttpMethod Method
- {
- get { return _method; }
- set
- {
- if (_method != SignHttpMethod.Get && _method != SignHttpMethod.Put)
- throw new ArgumentException("Only supports Get & Put method.");
- _method = value;
- }
- }
-
-
-
- public string BucketName { get; set; }
-
-
-
- public string Key { get; set; }
-
-
-
- public string ContentType { get; set; }
-
-
-
- public string ContentMd5 { get; set; }
-
-
-
- public DateTime Expiration { get; set; }
-
-
-
- public ResponseHeaderOverrides ResponseHeaders
- {
- get { return _responseHeader; }
- set
- {
- if (value == null)
- throw new ArgumentException("ResponseHeaderOverrides should not be null");
- _responseHeader = value;
- }
- }
-
-
-
-
- public IDictionary<string, string> UserMetadata
- {
- get { return _userMetadata; }
- set
- {
- if (value == null)
- throw new ArgumentException("UserMetadata should not be null");
- _userMetadata = value;
- }
- }
-
-
-
- public IDictionary<string, string> QueryParams
- {
- get { return _queryParams; }
- set
- {
- if (value == null)
- throw new ArgumentException("QueryParams should not be null");
- _queryParams = value;
- }
- }
-
-
-
-
-
- public void AddUserMetadata(string metaItem, string value)
- {
- _userMetadata.Add(metaItem, value);
- }
-
-
-
-
-
- public void AddQueryParam(string param, string value)
- {
- _queryParams.Add(param, value);
- }
-
-
-
-
-
- public GeneratePresignedUriRequest(string bucketName, string key)
- : this(bucketName, key, SignHttpMethod.Get)
- {
- }
-
-
-
-
-
-
- public GeneratePresignedUriRequest(string bucketName, string key, SignHttpMethod httpMethod)
- {
- OssUtils.CheckBucketName(bucketName);
- OssUtils.CheckObjectKey(key);
- BucketName = bucketName;
- Key = key;
- Method = httpMethod;
-
- Expiration = DateTime.Now.AddMinutes(15);
- }
-
- }
- }
|