मैं यह निर्धारित करने की कोशिश कर रहा हूं कि मेरे अमेज़ॅन एस 3 बाल्टी पर कोई फ़ोल्डर मौजूद है या नहीं और यदि मैं इसे बनाना नहीं चाहता हूं।अमेज़ॅन एस 3 प्रबंधन कंसोल के माध्यम से बनाम .NET एसडीके के माध्यम से फ़ोल्डर बनाना
फिलहालमैं फ़ोल्डर इस प्रकार नेट SDK का उपयोग बना सकते हैं:
public bool DoesFolderExist(string key, string bucketName)
{
try
{
S3Response response = m_S3Client.GetObjectMetadata(new GetObjectMetadataRequest()
.WithBucketName(bucketName)
.WithKey(key));
return true;
}
catch (Amazon.S3.AmazonS3Exception ex)
{
if (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
return false;
//status wasn't not found, so throw the exception
throw;
}
}
यह नहीं कर सकते हैं:
public void CreateFolder(string bucketName, string folderName)
{
var folderKey = folderName + "/"; //end the folder name with "/"
var request = new PutObjectRequest();
request.WithBucketName(bucketName);
request.StorageClass = S3StorageClass.Standard;
request.ServerSideEncryptionMethod = ServerSideEncryptionMethod.None;
//request.CannedACL = S3CannedACL.BucketOwnerFullControl;
request.WithKey(folderKey);
request.WithContentBody(string.Empty);
S3Response response = m_S3Client.PutObject(request);
}
अब जब मैं अगर फ़ोल्डर इस कोड का उपयोग मौजूद है देखने की कोशिश फ़ोल्डर ढूंढें। अजीब चीज यह है कि अगर मैं एडब्ल्यूएस प्रबंधन कंसोल का उपयोग कर फ़ोल्डर बना देता हूं, तो 'IsFolderExist' विधि इसे देख सकती है।
मुझे यकीन नहीं है कि यह एक एसीएल/आईएएम चीज है लेकिन मुझे यकीन नहीं है कि इसे कैसे हल किया जाए।
उपयोगी जानकारी - धन्यवाद –