-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths3.java
More file actions
41 lines (31 loc) · 1.39 KB
/
s3.java
File metadata and controls
41 lines (31 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import com.amazonaws.AmazonServiceException;
import com.amazonaws.SdkClientException;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import java.io.File;
import java.io.IOException;
public class UploadObject {
public static void saveCC(string creditCardNumber) throws IOException {
Regions clientRegion = Regions.DEFAULT_REGION;
String bucketName = "S3B_181355";
String stringObjKeyName = "XKIB5WDJHVGINH8YOZFC";
try {
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
.withRegion(clientRegion)
.build();
// Upload a text string with cc as a new object
s3Client.putObject(bucketName, stringObjKeyName, creditCardNumber);
} catch (AmazonServiceException e) {
// The call was transmitted successfully, but Amazon S3 couldn't process
// it, so it returned an error response.
e.printStackTrace();
} catch (SdkClientException e) {
// Amazon S3 couldn't be contacted for a response, or the client
// couldn't parse the response from Amazon S3.
e.printStackTrace();
}
}
}