Skip to content

HMT-112-profile-picture-storage #191

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions amplify/auth/PostConfirmation/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const handler: PostConfirmationTriggerHandler = async (event) => {
const cognitoGroupResponse = await cognitoClient.send(command);

const DDBResponse = await dataClient.models.User.create({
profilePicture: "",
firstName: "",
lastName: "",
role: "Participant",
Expand Down
3 changes: 3 additions & 0 deletions amplify/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { auth } from "@/amplify/auth/resource";
import { data } from "@/amplify/data/resource";
import { defineBackend } from "@aws-amplify/backend";

import { storage } from "./storage/resource";

const backend = defineBackend({
auth,
data,
storage,
});

// Cognito Email Overrides
Expand Down
1 change: 1 addition & 0 deletions amplify/data/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const schema = a
User: a
.model({
id: a.id().required(),
profilePicture: a.string(),
firstName: a.string(),
lastName: a.string(),
role: a
Expand Down
24 changes: 24 additions & 0 deletions amplify/storage/resource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineStorage } from "@aws-amplify/backend";

export const storage = defineStorage({
name: "profileImageStorage",
access: (allow) => ({
"public/*": [
allow.authenticated.to(["read", "write", "delete"]),
allow.groups(["Participant"]).to(["read", "write"]),
allow.groups(["Judge"]).to(["read", "write", "delete"]),
allow.groups(["Admin"]).to(["read", "write", "delete"]),
],
"private/${user}/profilePicture/*": [
// Allow users to manage their own profile pictures
allow.authenticated.to(["read", "write", "delete"]),
allow.groups(["Admin"]).to(["read", "write", "delete"]),
],
"media/*": [
allow.authenticated.to(["read", "write", "delete"]),
allow.groups(["Participant"]).to(["read", "write"]),
allow.groups(["Judge"]).to(["read", "write", "delete"]),
allow.groups(["Admin"]).to(["read", "write", "delete"]),
Copy link
Contributor

Choose a reason for hiding this comment

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

you resolved these, but I still don't see anywhere that you are using these...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ye mb i reverted this file on commit. Whoops

],
}),
});
5 changes: 4 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
domains: ["images.ctfassets.net"],
domains: [
"images.ctfassets.net",
"amplify-hackathonmanageme-profileimagestoragebucke-qigdi1utj018.s3.ca-central-1.amazonaws.com",
Copy link
Contributor

Choose a reason for hiding this comment

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

have to make this global, because this bucket is specific to you only

https://nextjs.org/docs/messages/next-image-unconfigured-host

you might have to upgrade next version to latest, which should be fine

],
},
};

Expand Down
Loading