mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2026-03-11 02:55:04 +00:00
Store Profile Picture on AWS
Save the profile picture to AWS so that the user need not retrieve it every time.
This commit is contained in:
34
Lambdas/Lists/Picture/src/PictureGetter.java
Normal file
34
Lambdas/Lists/Picture/src/PictureGetter.java
Normal file
@@ -0,0 +1,34 @@
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PictureGetter implements CallHandler {
|
||||
private final Connection connection;
|
||||
private final String cognitoID;
|
||||
|
||||
private final String GET_ITEM = "SELECT * FROM Pictures WHERE cognitoID = ?;";
|
||||
|
||||
public PictureGetter(Connection connection, String cognitoID) {
|
||||
this.connection = connection;
|
||||
this.cognitoID = cognitoID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryMap, String cognitoID) throws SQLException {
|
||||
PreparedStatement statement = connection.prepareStatement(GET_ITEM);
|
||||
if (!queryMap.get("id").toString().equals("profile")) {
|
||||
throw new IllegalArgumentException("Only profile pictures are currently supported.");
|
||||
}
|
||||
statement.setString(1, cognitoID);
|
||||
System.out.println(statement);
|
||||
ResultSet queryResults = statement.executeQuery();
|
||||
queryResults.first();
|
||||
System.out.println(queryResults);
|
||||
Picture retrievedPicture = new Picture(queryResults);
|
||||
// System.out.println(retrievedPicture);
|
||||
return retrievedPicture;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user