Skip to content
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

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from
Open

chore: Implement post upload endpoint #23

wants to merge 23 commits into from

Conversation

spenpal
Copy link

@spenpal spenpal commented Nov 4, 2019

Finished basic upload function

@WillieCubed WillieCubed self-requested a review November 4, 2019 21:36
Copy link
Contributor

@WillieCubed WillieCubed left a 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.

@@ -0,0 +1,5 @@
{
Copy link
Contributor

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):
Copy link
Contributor

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.

db = firestore.client()

firebase = pyrebase.initialize_app(firebaseConfig) # Intialize Firebase with configuration settings
Copy link
Contributor

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.

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 = {
Copy link
Contributor

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
Copy link
Contributor

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.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this. 😆

@WillieCubed WillieCubed changed the title Posts upload chore: Implement post upload endpoint Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants