public override string Get(int index)
        {
#if NETFX_CORE
            throw new PlatformNotSupportedException();
#else
            return(_actual.Get(index));
#endif
        }
Exemplo n.º 2
0
 static void DeletingAnObject()
 {
     try
     {
         DeleteObjectRequest request = new DeleteObjectRequest();
         request.WithBucketName(bucketName)
         .WithKey(keyName);
         using (DeleteObjectResponse response = client.DeleteObject(request))
         {
             System.Net.WebHeaderCollection headers = response.Headers;
             foreach (string key in headers.Keys)
             {
                 Console.WriteLine("Response Header: {0}, Value: {1}", key, headers.Get(key));
             }
         }
     }
     catch (AmazonS3Exception amazonS3Exception)
     {
         if (amazonS3Exception.ErrorCode != null &&
             (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||
              amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
         {
             Console.WriteLine("Please check the provided AWS Credentials.");
             Console.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
         }
         else
         {
             Console.WriteLine("An error occurred with the message '{0}' when deleting an object", amazonS3Exception.Message);
         }
     }
 }
Exemplo n.º 3
0
 // need the length for the progress bar
 private int GetContentLength(string url)
 {
     System.Net.WebHeaderCollection headers  = null;
     System.Net.HttpWebResponse     response = null;
     try {
         System.Net.HttpWebRequest request = System.Net.WebRequest.Create(url) as System.Net.HttpWebRequest;
         MarkNoCache(request);
         request.Method = "HEAD";
         response       = request.GetResponse() as System.Net.HttpWebResponse;
         headers        = response.Headers;
     } finally {
         //  avoid leaking connections
         if (response != null)
         {
             response.Close();
         }
     }
     if (headers.Get("Content-Length") != null)
     {
         return(System.Int32.Parse(headers.Get("Content-Length")));
     }
     return(-1);
 }