本文整理汇总了Java中com.amazonaws.services.s3.AmazonS3Client.doesObjectExist方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonS3Client.doesObjectExist方法的具体用法?Java AmazonS3Client.doesObjectExist怎么用?Java AmazonS3Client.doesObjectExist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.AmazonS3Client
的用法示例。
在下文中一共展示了AmazonS3Client.doesObjectExist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadToS3
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
public static void uploadToS3() {
// upload to s3 bucket
AWSCredentials awsCredentials = SkillConfig.getAWSCredentials();
AmazonS3Client s3Client = awsCredentials != null ? new AmazonS3Client(awsCredentials) : new AmazonS3Client();
File folder = new File("c:/temp/morse/" + DOT + "/mp3/");
File[] listOfFiles = folder.listFiles();
for (File file : listOfFiles) {
if (file.isFile()) {
if (!s3Client.doesObjectExist("morseskill", DOT + "/" + file.getName())) {
PutObjectRequest s3Put = new PutObjectRequest("morseskill", DOT + "/" + file.getName(), file).withCannedAcl(CannedAccessControlList.PublicRead);
s3Client.putObject(s3Put);
System.out.println("Upload complete: " + file.getName());
}
else {
System.out.println("Skip as " + file.getName() + " already exists.");
}
}
}
}
示例2: isImageAlreadyExisting
import com.amazonaws.services.s3.AmazonS3Client; //导入方法依赖的package包/类
public static Boolean isImageAlreadyExisting(String word, Boolean codeOnly) {
AWSCredentials awsCredentials = SkillConfig.getAWSCredentials();
AmazonS3Client s3Client = awsCredentials != null ? new AmazonS3Client(awsCredentials) : new AmazonS3Client();
return s3Client.doesObjectExist(SkillConfig.getS3BucketName(), getFileKey(word, codeOnly));
}