Exemplo n.º 1
0
        public ErrorTypes GetFileInfo(string strPath, out StorageFileInfo oStorageFileInfo)
        {
            oStorageFileInfo = null;
            ErrorTypes eError = ErrorTypes.StorageGetInfo;

            try
            {
                string strFileKey = GetFilePath(strPath);
                using (Amazon.S3.AmazonS3 oS3Client = Amazon.AWSClientFactory.CreateAmazonS3Client(m_oRegion))
                {
                    Amazon.S3.Model.GetObjectMetadataRequest oRequest = new Amazon.S3.Model.GetObjectMetadataRequest()
                                                                        .WithBucketName(m_strBucketName).WithKey(strFileKey);

                    using (Amazon.S3.Model.GetObjectMetadataResponse oResponse = oS3Client.GetObjectMetadata(oRequest))
                    {
                        oStorageFileInfo = new StorageFileInfo(oResponse.ContentLength, oResponse.LastModified);
                        eError           = ErrorTypes.NoError;
                    }
                }
            }
            catch
            {
            }
            return(eError);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets information and metadata for an object on
 /// S3 without needing to download it.
 /// </summary>
 /// <param name="bucket">The bucket that the object is in.</param>
 /// <param name="key">The key location for the object.</param>
 /// <returns></returns>
 public static Amazon.S3.Model.GetObjectMetadataResponse GetObjectMetadataResponse(string bucket, string key)
 {
     Amazon.S3.Model.GetObjectMetadataResponse response = new Amazon.S3.Model.GetObjectMetadataResponse();
     using (Amazon.S3.IAmazonS3 client = new Factory().S3Client())
     {
         Amazon.S3.Model.GetObjectMetadataRequest request = new Amazon.S3.Model.GetObjectMetadataRequest()
         {
             BucketName = bucket,
             Key = key
         };
         response = client.GetObjectMetadata(request);
     }
     return response;
 }