void validate(TransferUtilityUploadRequest request)
{
if (request == null)
{
throw new ArgumentNullException("request");
}
if (!request.IsSetBucketName())
{
throw new ArgumentNullException("bucketName");
}
if (!request.IsSetFilePath() &&
!request.IsSetInputStream())
{
throw new ArgumentException(
"Please specify either a Filename or provide a Stream to PUT an object into Amazon S3.");
}
if (!request.IsSetKey())
{
if (request.IsSetFilePath())
{
request.Key = new FileInfo(request.FilePath).Name;
}
else
{
throw new ArgumentException(
"The Key property must be specified when using a Stream to upload into Amazon S3.");
}
}
if (request.IsSetFilePath() && !File.Exists(request.FilePath))
{
throw new ArgumentException("The file indicated by the FilePath property does not exist!");
}
}