Amazon.S3.AmazonS3Client.GetObjectMetadata C# (CSharp) Method

GetObjectMetadata() public method

The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata. To use HEAD, you must have READ access to the object.
public GetObjectMetadata ( GetObjectMetadataRequest request ) : GetObjectMetadataResponse
request GetObjectMetadataRequest Container for the necessary parameters to execute the GetObjectMetadata service method.
return GetObjectMetadataResponse
        public GetObjectMetadataResponse GetObjectMetadata(GetObjectMetadataRequest request)
        {
            var marshaller = new GetObjectMetadataRequestMarshaller();
            var unmarshaller = GetObjectMetadataResponseUnmarshaller.Instance;

            return Invoke<GetObjectMetadataRequest,GetObjectMetadataResponse>(request, marshaller, unmarshaller);
        }

Same methods

AmazonS3Client::GetObjectMetadata ( string bucketName, string key ) : GetObjectMetadataResponse
AmazonS3Client::GetObjectMetadata ( string bucketName, string key, string versionId ) : GetObjectMetadataResponse

Usage Example

Example #1
0
 public bool InstanceExists(Guid instanceKey)
 {
     try
     {
         using (var client = new AmazonS3Client(Context.AwsAccessKeyId, Context.AwsSecretAccessKey))
         {
             using (var res = client.GetObjectMetadata(new GetObjectMetadataRequest()
             {
                 BucketName = Context.BucketName,
                 Key = string.Format("{0}/{1}/{2}", STR_INSTANCES_CONTAINER_PATH, instanceKey.ToString("N"), STR_INFO_FILE_NAME),
             })) { return true; }
         }
     }
     catch (AmazonS3Exception awsEx)
     {
         if (awsEx.StatusCode == System.Net.HttpStatusCode.NotFound)
         {
             return false;
         }
         else
         {
             throw new DeploymentException(string.Format("Failed getting instance with key \"{0}\"", instanceKey), awsEx);
         }
     }
 }
All Usage Examples Of Amazon.S3.AmazonS3Client::GetObjectMetadata
AmazonS3Client