-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fixes #24: Allow images to be uploaded when creating a new bug report. #679
Conversation
(The image/* filter accepts way more stuff than we want. See https://dxr.mozilla.org/mozilla-central/source/toolkit/content/filepicker.properties)
…put from being too big.
def testBadUploads(self): | ||
# Loop over some files and the status codes that we are expecting | ||
for filename, status_code in \ | ||
(('foo.xxx', 415), ('foo', 415), ('foo.rb', 415)): |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
I would love if @magsout could review the JavaScript. upload seems to me a bit too dangerous to just me thinking the JS is fine. I'll focus on the python code. |
Sounds good. The JS doesn't really do much with respect to uploads. Basically it's just duplicating the file validation on the client side that Flask-WTF is doing on the server side--so people don't have to submit an issue and get an error back (if they have JS enabled). But a sanity-check on |
|
||
# limit image uploads to 4MB | ||
patch_request_class(app, 4 * 1024 * 1024) | ||
|
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
||
from flask import abort | ||
from flask import Blueprint | ||
from flask import render_template |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@miketaylr I noticed something. First of all there are two nested uploads folder. Is it what you want?
Second, I would encourage to set a kind of dated space for the images inside upload. Something like
The reason is that the image are not stored into a database but in the filesystem. Filesystems have a tendency to become slow when the number of individual items grow into one unique directory. Having a dated space helps to create a partition that will reduce the number of images in one directory. It makes also less necessary to have a long hash_key, but that's secondary. |
self.assertEqual(rv.status_code, status_code) | ||
|
||
|
||
class TestingFileStorage(FileStorage): |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Oh, we can fix that. That's now actually how it's laid out on the server - just a goof up for the localhost stuff. |
Agreed, let me work on that today. |
r+ from me for the python side. Thanks a lot @miketaylr for your patience and the code. 💯 |
Thanks! Let's wait a day or two to see if @magsout can take a look. No real rush for this feature.
Cool. Also I need to file bugs (or find the ones that exist) for: adding upload form to issues/comments, drag & drop of images, API upload support for an arbitrary issue (then the stuff around screenshots). |
lgtm |
Thanks @magsout ! And let's pull it with love. |
Fixes #24: Allow images to be uploaded when creating a new bug report.
Good job everyone ❤️ |
There's a lot going on here, including:
New
upload
blueprint route (we'll make more use of this in the future when we add comment uploads and screenshot uploads).Adding a
<input type=file>
for our bug report form.Image uploading to the server.
Use Flask-Uploads for image uploading.
Use Flask-WTF for form handling and image type validation.
Clientside validation for image types.
Functional tests for clientside file validation.
Unit tests for new upload rote.
Thx to @magsout for his help with frontend, as always.
r? @karlcow