Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fd93070
Don't swallow the details of the exception.
Aug 7, 2015
a8d9c09
Issue #24. Add an upload blueprint + route.
Aug 10, 2015
6cce652
Issue #24. Serve images from Flask -- but only for local development.
Aug 10, 2015
df49e0b
Issue #24. Update config.py.example with new config settings.
Aug 10, 2015
59b51ed
Issue #24. Hook up image uploading with bug reporting.
Aug 10, 2015
35dd685
Issue #24. Tweak upload form label and add accept attr to input[type=…
Aug 11, 2015
0300844
Issue #24. Be less liberal and only accept: jpeg, png, gif and bmp.
Aug 11, 2015
174636d
Issue #24. Display errors in template for image uploading.
Aug 11, 2015
4d2c359
Issue #24. Only try to add an image to the issue... if there's an image.
Aug 11, 2015
6f593c6
Issue #24. Clean up the BugForm consructor object.
Aug 12, 2015
f521304
Issue #24. Show loader when uploading an image.
Aug 12, 2015
1cb0588
Issue #24 - added icon upload
magsout Aug 14, 2015
c3c9ec0
Issue #24. Add note about uploads config error.
Aug 14, 2015
d39f21d
Issues #24 - added style and icon for upload button
magsout Aug 14, 2015
47ffe9c
Issue #24: Add pos: relative to wc-Form-upload to prevent pos: abs in…
Aug 17, 2015
d9e7e59
Issue #24: Add missing url form error class.
Aug 17, 2015
8457d9e
Issue #24: Use Flask-WTF for crsf + File upload validation.
Aug 17, 2015
d70f002
Issue #24: Add unit tests for uploads.
Aug 17, 2015
fa895e1
Issue #24: Do clientside validation for image type.
Aug 18, 2015
c1c70eb
Issue #24: Split up form validation tests and add one for valid images.
Aug 18, 2015
7a26480
Issue #24. Remove unused method import.
Aug 18, 2015
b46af3d
Issue #24. Re-format how we print ImportErrors to the console.
Aug 19, 2015
2162300
Issue #24. Reformat some for loops.
Aug 19, 2015
abbbd9a
Issue #24. Remove unused import.
Aug 20, 2015
c8dc773
Issue #24: Import TestingFileStorage (oops)
Aug 20, 2015
ef65a53
Issue #24: Remove extra uploads/ dir for localhost.
Aug 20, 2015
bb9c875
Issue #24. Obfuscate the uploaded filename.
Aug 20, 2015
bd14e70
Issue #24. Save uploads to a year/month/ namespaced location.
Aug 20, 2015
3790df1
Issue #24. Update privacy policy to mention image uploads.
Aug 21, 2015
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
Prev Previous commit
Next Next commit
Issue #24. Save uploads to a year/month/ namespaced location.
  • Loading branch information
Mike Taylor
Mike Taylor committed Aug 20, 2015
commit bd14e705ef70672c9241d1a8fb1eef44834c4f79
11 changes: 9 additions & 2 deletions webcompat/api/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
'''Flask Blueprint for image uploads.'''

import json
import os

from datetime import date
from flask import abort
from flask import Blueprint
from flask import request
Expand All @@ -30,19 +32,24 @@
# limit image uploads to 4MB
patch_request_class(app, 4 * 1024 * 1024)

This comment was marked as abuse.

#TODO dated namespace

@uploads.route('/', methods=['POST'])
def upload():
'''Endpoint to upload an image.

If the image asset passes validation, it's saved as:
UPLOADS_DEFAULT_DEST + /year/month/random-uuid.ext

Returns a JSON string that contains the filename and url.
'''
if request.method == 'POST' and 'image' in request.files:
try:
file = request.files['image']
file_ext = file.filename.split('.')[-1]
filename = str(uuid4()) + '.' + file_ext
today = date.today()
filename = os.path.join(str(today.year),
str(today.month),
str(uuid4()) + '.' + file_ext)
images.save(file, name=filename)
data = {
'filename': filename,
Expand Down