/* * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using System; using System.Collections.Generic; using System.Globalization; namespace Amazon.S3.Model { /// /// This class contains browser post supported headers for an S3 object. /// public sealed class HeadersCollectionPost { readonly IDictionary _values = new Dictionary(StringComparer.OrdinalIgnoreCase); /// /// Gets and sets headers to set for the object. /// /// The name of the header /// The value for the header public string this[string name] { get { string value; if (_values.TryGetValue(name, out value)) return value; return null; } set { if (value != null) { _values[name] = value; } else if (_values.ContainsKey(name)) { _values.Remove(name); } } } /// /// Gets the count of headers. /// public int Count { get { return this._values.Count; } } /// /// Gets the names of the headers set. /// public ICollection Keys { get { return _values.Keys; } } /// /// Specifies caching behavior along the request/reply chain. /// public string CacheControl { get { return this["Cache-Control"]; } set { this["Cache-Control"] = value; } } /// /// Specifies presentational information for the object. /// public string ContentDisposition { get { return this["Content-Disposition"]; } set { this["Content-Disposition"] = value; } } /// /// Specifies what content encodings have been applied to the object and thus what decoding mechanisms must be applied to obtain the media-type /// public string ContentEncoding { get { return this["Content-Encoding"]; } set { this["Content-Encoding"] = value; } } /// /// Content type for the uploaded data /// /// /// If this is not set, an attempt will be made to infer it from the extension on Key or Path (in that order), /// otherwise 'application/octet-stream' will be assumed. /// public string ContentType { get { return this["Content-Type"]; } set { this["Content-Type"] = value; } } internal bool IsSetContentType() { return !string.IsNullOrEmpty(this.ContentType); } /// /// The date and time at which the object is no longer cacheable. /// public DateTime? Expires { get { if (this["Expires"] == null) return null; return DateTime.Parse(this["Expires"], CultureInfo.InvariantCulture); } set { if (value == null) this["Expires"] = null; this["Expires"] = value.GetValueOrDefault().ToString(Amazon.Util.AWSSDKUtils.RFC822DateFormat, CultureInfo.InvariantCulture); } } } }