Skip to content

Made database store full url #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public UploadVideoResponse handleRequest(UploadVideoPostRequest uploadVideoPostR
String videoKey =
generateUniqueBucketKeyForVideo() + ".ogg";
S3Util.getInstance().uploadVideoToBucket(BUCKET_LOCATION, videoKey, uploadVideoPostRequest.getVideo());

String url = S3Util.getInstance().getUrl(BUCKET_LOCATION, videoKey);
//Insert into the videos table
Video insertVideo = new Video(uploadVideoPostRequest.getName(), "/" + videoKey, uploadVideoPostRequest.getDialogue());
Video insertVideo = new Video(uploadVideoPostRequest.getName(), url, uploadVideoPostRequest.getDialogue());
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic work 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't agree more

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚰️ ⚰️ url bad ⚰️ ⚰️

insertVideo.id = VideoDAO.getInstance().createVideo(insertVideo);

//Parse the characters passed in as a string and turn them into character objects
Expand Down
7 changes: 7 additions & 0 deletions youTrek/src/main/java/youtrek/s3/S3Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public void deleteFile(String bucketName, String fileName) throws Exception{
s3.deleteObject(bucketName, fileName);
}

public String getUrl(String bucketName, String fileName) throws Exception{
final AmazonS3 s3 = AmazonS3ClientBuilder.standard()
.withRegion(Regions.US_EAST_2) //Stick to Ohio region because that's where our buckets are located
.build();

return s3.getUrl(bucketName, fileName).toString();
}


//Exception should bubble up
Expand Down