Java
Chilkat2 Java
Example: Http.S3_FileExists method
Demonstrates theS3_FileExists method.
Chilkat Java Downloads
import com.chilkatsoft.chilkat2.Http;
public class ChilkatExample {
public static void main(String[] args) {
Http http = new Http();
// Insert your AWS keys here:
http.setAwsAccessKey("AWS_ACCESS_KEY");
http.setAwsSecretKey("AWS_SECRET_KEY");
String bucketName = "chilkat.ocean";
String objectName = "seahorse.jpg";
http.setAwsRegion("us-west-2");
http.setAwsEndpoint("s3-us-west-2.amazonaws.com");
int retval = http.s3FileExists(bucketName, objectName);
if (retval < 0) {
System.out.println("Failed to check for the S3 object existence");
System.out.println(http.getLastErrorText());
return;
}
if (retval == 0) {
System.out.println("The S3 object does not exist.");
return;
}
System.out.println("The S3 object exists.");
}
}