-
Notifications
You must be signed in to change notification settings - Fork 4
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
chore: Implement post upload endpoint #23
base: dev
Are you sure you want to change the base?
Conversation
This is a Mac-only file that should not be the code repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks good to me as we'll have to talk about our final implementation for post uploads at the next meeting, but make the requested changes then I'll review them again.
.vscode/settings.json
Outdated
@@ -0,0 +1,5 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference, don't check IDE preferences into Git. I'd actually recommend adding this to the .gitignore
file, untracking this file, then committing.
@@ -6,11 +6,10 @@ class PostMetadata: | |||
machine learning. | |||
""" | |||
|
|||
def __init__(self, id: str, image_url: str, hashtags: list, caption: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, we're going to have to rewrite a lot of the models with the new spec.
backend/posts/posts.py
Outdated
db = firestore.client() | ||
|
||
firebase = pyrebase.initialize_app(firebaseConfig) # Intialize Firebase with configuration settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice this the first time around, but we're going to have to use a different means (not pyrebase, which is unmaintained) to access Cloud Storage.
backend/posts/posts.py
Outdated
from google.cloud.exceptions import NotFound | ||
from intelligence import generate_image_metadata | ||
from models import AddPostMetadata, PostMetadata | ||
from exceptions import CreatePostException, GetPostException, UnknownPostIdException, DeletePostException | ||
|
||
COLLECTION_POSTS = u'/posts' | ||
|
||
|
||
firebaseConfig = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we're deploying this on Google Cloud Functions, Application Default Credentials will be the means by which we authenticate our access to Firebase APIs.
It's technically okay to check these into version control as they are meant for the web, which is inherently public, but we'll remove these later.
backend/main.py
Outdated
if imageUrl is None or imageUrl == '' | ||
add_post_metadata = AddPostMetadata() | ||
# TODO: Handle uploads | ||
# TODO: Upload photo from request to Cloud Storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the completed to-dos here.
except CreatePostException: | ||
response = _generate_server_error() | ||
else: | ||
error_body = { | ||
'errorCode': 'methodNotSupported', | ||
'message': 'This HTTP method is support supported by this server.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this. 😆
Finished basic upload function