本文整理汇总了C#中Amazon.S3.Model.DeleteObjectRequest类的典型用法代码示例。如果您正苦于以下问题:C# DeleteObjectRequest类的具体用法?C# DeleteObjectRequest怎么用?C# DeleteObjectRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeleteObjectRequest类属于Amazon.S3.Model命名空间,在下文中一共展示了DeleteObjectRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteFile
// Delete file from the server
private void DeleteFile(HttpContext context)
{
var _getlen = 10;
var fileName = context.Request["f"];
var fileExt = fileName.Remove(0,fileName.LastIndexOf('.')).ToLower();
var hasThumb = Regex.Match(fileName.ToLower(),AmazonHelper.ImgExtensions()).Success;
var keyName = GetKeyName(context,HttpUtility.UrlDecode(context.Request["f"]));
var client = AmazonHelper.GetS3Client();
var extrequest = new GetObjectRequest()
.WithByteRange(0,_getlen)
.WithKey(keyName)
.WithBucketName(StorageRoot);
var extresponse = client.GetObject(extrequest);
var length = extresponse.ContentLength;
extresponse.Dispose();
if(length == _getlen + 1){
var delrequest = new DeleteObjectRequest()
.WithKey(keyName)
.WithBucketName(StorageRoot);
var delresponse = client.DeleteObject(delrequest);
delresponse.Dispose();
if(hasThumb){
try
{
keyName = keyName.Replace(fileName,"thumbs/" + fileName.Replace(fileExt,".png"));
var thumbcheck = new GetObjectRequest()
.WithByteRange(0,_getlen)
.WithKey(keyName)
.WithBucketName(StorageRoot);
var thumbCheckResponse = client.GetObject(thumbcheck);
length = extresponse.ContentLength;
thumbCheckResponse.Dispose();
if(length == _getlen + 1){
var thumbdelrequest = new DeleteObjectRequest()
.WithKey(keyName)
.WithBucketName(StorageRoot);
var thumbdelresponse = client.DeleteObject(thumbdelrequest);
delresponse.Dispose();
}
}
catch (Exception ex)
{
var messg = ex.Message;
}
}
}
}
示例2: DeleteFile
public void DeleteFile(String filename)
{
String key = filename;
var amazonClient = new AmazonS3Client(_keyPublic, _keySecret);
var deleteObjectRequest = new DeleteObjectRequest { BucketName = _bucket, Key = key };
var response = amazonClient.DeleteObject(deleteObjectRequest);
}
示例3: 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));
}
}
}
示例4: 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";
}
示例5: PhysicallyDeletePhoto
public static S3Response PhysicallyDeletePhoto(AmazonS3 anS3Client, string aBucketName, string aFileName)
{
DeleteObjectRequest myDeleteRequest = new DeleteObjectRequest();
myDeleteRequest.WithBucketName(aBucketName).WithKey(aFileName);
return anS3Client.DeleteObject(myDeleteRequest);
}
示例6: 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();
}
示例7: TestCleanup
public void TestCleanup()
{
var deleteRequest = new DeleteObjectRequest()
.WithBucketName(bucket.BucketName)
.WithKey(this.objKey);
using (var deleteResponse = client.DeleteObject(deleteRequest)) { }
}
示例8: ProcessRecord
protected override void ProcessRecord()
{
AmazonS3 client = base.GetClient();
Amazon.S3.Model.DeleteObjectRequest request = new Amazon.S3.Model.DeleteObjectRequest();
request.BucketName = this._BucketName;
request.Key = this._Key;
request.VersionId = this._VersionId;
Amazon.S3.Model.DeleteObjectResponse response = client.DeleteObject(request);
}
示例9: DeleteS3Object
private static void DeleteS3Object(string key)
{
DeleteObjectRequest deleteRequest = new DeleteObjectRequest
{
BucketName = BucketName,
Key = key
};
_amazonS3Client.DeleteObject(deleteRequest);
}
示例10: DeleteItemAsync
private async Task<DeleteObjectResponse> DeleteItemAsync(AmazonS3Client s3Client, string bucketName, string path, CancellationToken token)
{
var request = new DeleteObjectRequest()
{
BucketName = bucketName,
Key = path + _itemChange.Item.Path
};
return await s3Client.DeleteObjectAsync(request, token);
}
示例11: DeleteFile
public static void DeleteFile(AmazonS3 Client, string filekey)
{
DeleteObjectRequest request = new DeleteObjectRequest()
{
BucketName = BUCKET_NAME,
Key = filekey
};
S3Response response = Client.DeleteObject(request);
}
示例12: StateDelete
public void StateDelete(string appId, string key)
{
var deleteObjectRequest = new DeleteObjectRequest
{
BucketName = ConfigurationManager.AppSettings["BucketName"],
Key = string.Format("{0}/{1}", appId, key)
};
WebApiApplication.AmazonS3Client.DeleteObject(deleteObjectRequest);
}
示例13:
Task ICoreAmazonS3.DeleteAsync(string bucketName, string objectKey, IDictionary<string, object> additionalProperties, CancellationToken cancellationToken)
{
var request = new DeleteObjectRequest
{
BucketName = bucketName,
Key = objectKey
};
InternalSDKUtils.ApplyValues(request, additionalProperties);
return this.DeleteObjectAsync(request, cancellationToken);
}
示例14: Delete
//Deletes a file
public void Delete(string fileName)
{
IAmazonS3 client = GetS3Client();
var request = new DeleteObjectRequest
{
BucketName = _BucketName,
Key = _Prefix + fileName
};
client.DeleteObject(request);
}
示例15: 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();
}