· 7 years ago · Apr 06, 2018, 09:06 PM
1public static void main(String[] args) {
2
3 final ClientConfiguration clientConfiguration = new ClientConfiguration().withMaxErrorRetry(0);
4 final AmazonS3Client client = new AmazonS3Client(new BasicAWSCredentials("accessKey", "secretKey"), clientConfiguration);
5
6 for (long i = 1; i <= 20; i++) {
7 ObjectMetadata meta = new ObjectMetadata();
8 meta.setContentType("application/json");
9 ByteArrayInputStream stream = new ByteArrayInputStream("Test Me Hard!".getBytes(StandardCharsets.UTF_8));
10 PutObjectRequest request = new PutObjectRequest("my.test.bucket.dev", "test/text.txt", stream, meta);
11 try {
12 System.out.println("Iteration number" + i);
13 client.putObject(request);
14 } catch (Exception e) {
15 e.printStackTrace();
16 }
17 try {
18 Thread.sleep(6000);
19 } catch (InterruptedException e) {
20 e.printStackTrace();
21 }
22 }
23 }