/// <summary>
/// Write the multipart/form-data for this request for all fields except the file data to a stream
/// </summary>
internal void WriteFormData(string boundary, Stream outputStream)
{
if (!String.IsNullOrEmpty(this.Key))
{
WriteFormDatum(outputStream, S3Constants.PostFormDataObjectKey, this.Key, boundary);
}
WriteFormDatum(outputStream, S3Constants.PostFormDataAcl, this.CannedACL, boundary);
if (this._isSetStorageClass)
{
WriteFormDatum(outputStream, HeaderKeys.XAmzStorageClassHeader, this.StorageClass, boundary);
}
if (this._isSetActionStatus)
{
WriteFormDatum(outputStream, S3Constants.PostFormDataStatus, ((Int32)this.SuccessActionStatus).ToString(CultureInfo.InvariantCulture), boundary);
}
if (!String.IsNullOrEmpty(this.SuccessActionRedirect))
{
WriteFormDatum(outputStream, S3Constants.PostFormDataRedirect, this.SuccessActionRedirect, boundary);
}
if (String.IsNullOrEmpty(this.ContentType))
{
if (this.Key.IndexOf('.') > -1)
{
this.ContentType = AmazonS3Util.MimeTypeFromExtension(this.Key.Substring(this.Key.LastIndexOf('.')));
}
else if (!String.IsNullOrEmpty(this.Path) && this.Path.IndexOf('.') > -1)
{
this.ContentType = AmazonS3Util.MimeTypeFromExtension(this.Key.Substring(this.Path.LastIndexOf('.')));
}
}
WriteFormDatum(outputStream, S3Constants.PostFormDataContentType, this.ContentType, boundary);
if (this.SignedPolicy != null && !string.IsNullOrEmpty(this.SignedPolicy.SecurityToken))
{
this.Metadata[S3Constants.PostFormDataSecurityToken] = this.SignedPolicy.SecurityToken;
}
foreach (var kvp in this.Metadata)
{
var metakey = kvp.Key.StartsWith(S3Constants.PostFormDataXAmzPrefix, StringComparison.Ordinal) ? kvp.Key : S3Constants.PostFormDataMetaPrefix + kvp.Key;
WriteFormDatum(outputStream, metakey, kvp.Value, boundary);
}
if (this.SignedPolicy != null)
{
WriteFormDatum(outputStream, S3Constants.PostFormDataAccessKeyId, this.SignedPolicy.AccessKeyId, boundary);
WriteFormDatum(outputStream, S3Constants.PostFormDataPolicy, this.SignedPolicy.Policy, boundary);
WriteFormDatum(outputStream, S3Constants.PostFormDataSignature, this.SignedPolicy.Signature, boundary);
}
}