티스토리 뷰

반응형
bool ListObject() {

	int cnt = 0;
	Aws::String endp = "kr.object.ncloudstorage.com";

	Aws::Client::ClientConfiguration config;

	config.endpointOverride = endp;
	config.region = "kr-standard";
	config.scheme = Aws::Http::Scheme::HTTP;

	Aws::S3::S3Client s3_client(Aws::Auth::AWSCredentials(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY),
		config);


	Aws::S3::Model::ListObjectsRequest request;
	request.WithBucket(bucket_name);

	bool isDone = false;
	
	while (!isDone)
	{
		auto list_objects_outcome = s3_client.ListObjects(request);

		Aws::Vector<Aws::S3::Model::Object> object_list =
			list_objects_outcome.GetResult().GetContents();

		for (auto const &s3_object : object_list)
		{
			std::cout << cnt << s3_object.GetKey() << std::endl;
			cnt++;
		}

		isDone = !list_objects_outcome.GetResult().GetIsTruncated();

		if (!isDone)
			request.SetMarker(list_objects_outcome.GetResult().GetNextMarker());
	}

		
	
	return true;
}
댓글

티스토리 방명록

최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday