本文整理汇总了C#中Amazon.S3.Model.DeleteObjectRequest.WithBucketName方法的典型用法代码示例。如果您正苦于以下问题:C# DeleteObjectRequest.WithBucketName方法的具体用法?C# DeleteObjectRequest.WithBucketName怎么用?C# DeleteObjectRequest.WithBucketName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amazon.S3.Model.DeleteObjectRequest
的用法示例。
在下文中一共展示了DeleteObjectRequest.WithBucketName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PhysicallyDeletePhoto
public static S3Response PhysicallyDeletePhoto(AmazonS3 anS3Client, string aBucketName, string aFileName)
{
DeleteObjectRequest myDeleteRequest = new DeleteObjectRequest();
myDeleteRequest.WithBucketName(aBucketName).WithKey(aFileName);
return anS3Client.DeleteObject(myDeleteRequest);
}
示例2: DeleteDocument
public void DeleteDocument(string keyName)
{
try
{
using (var client = GetClient)
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName(ImagesBucketName)
.WithKey(keyName);
client.DeleteObject(request);
}
}
catch (AmazonS3Exception amazonS3Exception)
{
if (amazonS3Exception.ErrorCode != null &&
(amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") ||
amazonS3Exception.ErrorCode.Equals("InvalidSecurity")))
{
throw new Exception("Please check the provided AWS Credentials.");
}
else
{
throw new Exception(string.Format("An error occurred with the message '{0}' when deleting an object", amazonS3Exception.Message));
}
}
}
示例3: DeleteImageFile
public string DeleteImageFile(Hashtable State, string url)
{
string AWSAccessKey = ConfigurationManager.AppSettings["AWSAccessKey"];
string AWSSecretKey = ConfigurationManager.AppSettings["AWSSecretKey"];
string Bucket = ConfigurationManager.AppSettings["ImageBucket"];
TransferUtility transferUtility = new TransferUtility(AWSAccessKey, AWSSecretKey);
try
{
DeleteObjectRequest request = new DeleteObjectRequest();
string file_name = url.Substring(url.LastIndexOf("/") + 1);
string key = State["Username"].ToString() + "/" + file_name;
request.WithBucketName(Bucket)
.WithKey(key);
using (DeleteObjectResponse response = transferUtility.S3Client.DeleteObject(request))
{
WebHeaderCollection headers = response.Headers;
}
}
catch (AmazonS3Exception ex)
{
Util util = new Util();
util.LogError(State, ex);
return ex.Message + ": " + ex.StackTrace;
}
return "OK";
}
示例4: DeletingAnObject
public static void DeletingAnObject(AmazonS3Client client, string bucketName, string keyName)
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName(bucketName)
.WithKey(keyName);
S3Response response = client.DeleteObject(request);
response.Dispose();
}
示例5: RemoveFileFromBucket
public static void RemoveFileFromBucket(string fileName)
{
// remove file from S3
var client = InitS3Client();
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName(WebConfig.Get("awsbucket"));
request.Key = fileName;
S3Response response = client.DeleteObject(request);
response.Dispose();
}
示例6: DeletingObject
public void DeletingObject(string keyName)
{
var deleteRequest = new DeleteObjectRequest();
deleteRequest.WithBucketName(BucketName)
.WithKey(keyName);
using (AmazonS3 client = AWSClientFactory.CreateAmazonS3Client(AccessKeyId, SecretAccessKeyId))
{
DeleteObjectResponse response = client.DeleteObject(deleteRequest);
}
}
示例7: DeleteFile
/// <summary>
/// Deletes a file
/// </summary>
/// <param name="path">Web path to file's folder</param>
/// <param name="fileName">File name</param>
public void DeleteFile(string path, string fileName)
{
// Prepare delete request
var request = new DeleteObjectRequest();
request.WithBucketName(_bucketName)
.WithKey(GetKey(path, fileName));
// Delete file
var response = _client.DeleteObject(request);
response.Dispose();
}
示例8: DeleteFile
public static bool DeleteFile(string name)
{
try
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName(BucketName)
.WithKey(name);
AmazonS3Config config = new AmazonS3Config();
config.CommunicationProtocol = Protocol.HTTP;
using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(AccessKeyID, SecretAccessKeyID, config))
using (DeleteObjectResponse response = client.DeleteObject(request))
{
if (response != null)
return true;
else
return false;
}
}
catch (AmazonS3Exception amazonS3Exception)
{
#if(DEBUG)
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);
}
#endif
return false;
}
catch (Exception e)
{
return false;
}
}
示例9: DeleteImage
/// <summary>
/// Delete the specified image
/// </summary>
/// <param name="filePath"></param>
/// <param name="fileName"></param>
public override void DeleteImage(string filePath, string key)
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName("images.climbfind.com" + filePath)
.WithKey(key);
using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(Stgs.AWSAccessKey, Stgs.AWSSecretKey, S3Config))
{
// simple object put
using (DeleteObjectResponse response = client.DeleteObject(request))
{
//-- Do a little bit of tracing
string headersString = string.Empty;
WebHeaderCollection headers = response.Headers;
foreach (string h in headers.Keys)
{
headersString += string.Format("Response Header: {0}, Value: {1}", h, headers.Get(h));
}
CfTrace.Information(TraceCode.DeletingImage, headersString);
}
}
}
示例10: DeleteS3Object
public string DeleteS3Object(string Bucket, string key)
{
string AWSAccessKey = ConfigurationManager.AppSettings["AWSAccessKey"];
string AWSSecretKey = ConfigurationManager.AppSettings["AWSSecretKey"];
TransferUtility transferUtility = new TransferUtility(AWSAccessKey, AWSSecretKey);
try
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName(Bucket)
.WithKey(key);
using (DeleteObjectResponse response = transferUtility.S3Client.DeleteObject(request))
{
WebHeaderCollection headers = response.Headers;
}
}
catch (AmazonS3Exception ex)
{
return ex.Message + ": " + ex.StackTrace;
}
return "OK";
}
示例11: Delete
public void Delete(string key)
{
var deleteObject = new DeleteObjectRequest();
deleteObject.WithBucketName(this._bucketName).WithKey(key);
this._client.DeleteObject(deleteObject);
}
示例12: JSONDeleteAWSFile
public JsonResult JSONDeleteAWSFile(string key)
{
var request = new DeleteObjectRequest();
request.WithBucketName(AWSBucket)
.WithKey(key);
using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey))
{
using (DeleteObjectResponse response = client.DeleteObject(request)) { }
}
return Json(null);
}
示例13: DeleteFile
public void DeleteFile(string path)
{
using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey, _S3Config))
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName(BucketName)
.WithKey(path);
using (DeleteObjectResponse response = client.DeleteObject(request))
{
}
}
}
示例14: DeleteFolder
public void DeleteFolder(string path)
{
//TODO: recursive on all keys with prefix
using (var client = Amazon.AWSClientFactory.CreateAmazonS3Client(AWSAccessKey, AWSSecretKey, _S3Config))
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName(BucketName)
.WithKey(path);
using (DeleteObjectResponse response = client.DeleteObject(request))
{
}
}
}
示例15: DeletingAWS
public ActionResult DeletingAWS(string keyName)
{
if (!checkRequiredFields())
{
ViewBag.Result = "";
return View();
}
try
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName(bucketName)
.WithKey(keyName);
AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(RegionEndpoint.APSoutheast1);
DeleteObjectResponse response = client.DeleteObject(request);
//using (DeleteObjectResponse response = client.DeleteObject(request))
//{
// 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);
}
NotificationHandler.setNotification(NotificationHandler.NOTY_ERROR, "Error removing the file from our File System, this file record is now removed");
}
return View("Refresh");
}