本文整理汇总了C#中Amazon.S3.Model.ListObjectsRequest.WithBucketName方法的典型用法代码示例。如果您正苦于以下问题:C# ListObjectsRequest.WithBucketName方法的具体用法?C# ListObjectsRequest.WithBucketName怎么用?C# ListObjectsRequest.WithBucketName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amazon.S3.Model.ListObjectsRequest
的用法示例。
在下文中一共展示了ListObjectsRequest.WithBucketName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteFolder
/// <summary>
/// Delete a folder
/// </summary>
/// <param name="prefix">prefix</param>
public void DeleteFolder(string prefix)
{
// Get all object with specified prefix
var listRequest = new ListObjectsRequest();
listRequest.WithBucketName(_bucketName).WithPrefix(prefix);
var deleteRequest = new DeleteObjectsRequest();
deleteRequest.BucketName = _bucketName;
do
{
ListObjectsResponse listResponse = _client.ListObjects(listRequest);
// Add all object with specified prefix to delete request.
foreach (S3Object entry in listResponse.S3Objects)
{
deleteRequest.AddKey(entry.Key);
}
if (listResponse.IsTruncated)
{
listRequest.Marker = listResponse.NextMarker;
}
else
{
listRequest = null;
}
}
while (listRequest != null);
// Delete all the object with specified prefix.
if (deleteRequest.Keys.Count > 0)
{
var deleteResponse = _client.DeleteObjects(deleteRequest);
deleteResponse.Dispose();
}
}
示例2: deleteFile
private void deleteFile(bool hasFile, string fileType, int id)
{
if (hasFile)
{
DeleteObjectRequest request = new DeleteObjectRequest();
request.WithBucketName("intelrecruiter");
ListObjectsRequest listObjReq = new ListObjectsRequest();
listObjReq.WithBucketName("intelrecruiter")
.WithPrefix(fileType + "/" + id.ToString());
using (client = Amazon.AWSClientFactory.CreateAmazonS3Client("AKIAJ47VSG7WMA62WLCA", "3tqlHujlftpk6j/z5OtDw2eg9N2FJtz1RwL8bEa3"))
{
var results = client.ListObjects(listObjReq).S3Objects;
foreach (var obj in results)
{
request.Key = obj.Key;
client.DeleteObject(request);
}
}
}
}
示例3: ListObjectsInBucket
//***
public System.Tuple<bool, List<string>> ListObjectsInBucket(AmazonS3Client client, string bucketName)
{
try
{
ListObjectsRequest request = new ListObjectsRequest();
request.WithBucketName(bucketName);
ListObjectsResponse response = client.ListObjects(request);
List<string> retList = new List<string>();
foreach (S3Object s3Object in response.S3Objects)
retList.Add(s3Object.Key);
return new System.Tuple<bool, List<string>>(false, retList);
}
catch (Exception e)
{
return new System.Tuple<bool, List<string>>(false, new List<string>() { e.ToString()});
}
}
示例4: ListObjects
private static void ListObjects(AmazonS3 s3Client, string bucket)
{
var request = new ListObjectsRequest();
request.WithBucketName(bucket)
.WithPrefix("key")
.WithMaxKeys(4);
do
{
ListObjectsResponse response = s3Client.ListObjects(request);
if (response.IsTruncated)
{
request.Marker = response.NextMarker;
}
else
{
request = null;
}
} while (request != null);
}