Skip to content

Commit

Permalink
ID-#2 AWS JAVA SDK Sample Ok
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloEzequiel committed Jul 31, 2020
1 parent ef9a243 commit bb618d4
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
import java.net.HttpURLConnection;
import java.net.URL;


/**
* Saple code from:
* https://docs.aws.amazon.com/AmazonS3/latest/dev/PresignedUrlUploadObjectJavaSDK.html
*/
public class GeneratePresignedUrlAndUploadObject {

public static void main(String[] args) throws IOException {
Regions clientRegion = Regions.US_EAST_1; // Regions.DEFAULT_REGION;
String bucketName = "fruta-web";
String objectKey = "miobjeto";
String objectKey = "miobjeto2";

try {
AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
Expand All @@ -41,6 +46,9 @@ public static void main(String[] args) throws IOException {
.withExpiration(expiration);
URL url = s3Client.generatePresignedUrl(generatePresignedUrlRequest);


System.out.println("PresignedUrlRequest: " + url);

// Create the connection and use it to upload the new object using the pre-signed URL.
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
Expand Down

0 comments on commit bb618d4

Please sign in to comment.