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

Add file uploader #36

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open

Add file uploader #36

wants to merge 30 commits into from

Conversation

raynei86
Copy link
Collaborator

@raynei86 raynei86 commented Aug 1, 2024

Overview of the feature can be found in docs/.

Note: There are two times when file validation is run. One size validation is ran on the client, a second "fake" file type validation is run on WTForms. The type validation only checks the file extension and not the bytes, so it can be improved.

A few improvements to be made:

  • Add true binary level file validation
  • Beautify response when file size is too large: 677acd5
  • Remove remnants of the IMAGE_HOST_URL variable in .env.example
  • The file is removed from the server after being uploaded to Azure, but the directory remains on the server. See comments in 52cce58

raynei86 added 30 commits July 22, 2024 13:18
The code was expecting an environment variable called `DATABASE_URL`,
not the default `SQLALCHEMY_DATABASE_URI`.
Parsley could be used, but there is so much boilerplate for defining
custom validators that it doesn't justify a one time use. Though this
does mean a very intrusive and primitive alert dialog.
The scope of `blob_name` is inside the if statement, inaccessible to
the `create_story()` call. This commit brings the variable to the same scope
as the call.
It's a more appropriate location as they're related to stories, not
the database.
This feature is too generic to be just inside the story view.
@raynei86 raynei86 requested a review from zgary August 1, 2024 17:11
with open(file_path, "rb") as data:
blob_client.upload_blob(data, overwrite=True)

os.remove(os.path.abspath(file_path))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This removes the file but the directory still remains.

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.

1 participant