Commit d0ac1227 by David Ormsbee

Merge pull request #460 from MITx/kimth/multiple-fileupload

Kimth/multiple fileupload
parents b200da39 4ff08860
......@@ -83,6 +83,9 @@ class XQueueInterface(object):
if error and (msg == 'login_required'): # Log in, then try again
self._login()
if files_to_upload is not None:
for f in files_to_upload: # Need to rewind file pointers
f.seek(0)
(error, msg) = self._send_to_queue(header, body, files_to_upload)
return (error, msg)
......
......@@ -379,6 +379,12 @@ def modx_dispatch(request, dispatch=None, id=None, course_id=None):
if request.FILES:
for fileinput_id in request.FILES.keys():
inputfiles = request.FILES.getlist(fileinput_id)
if len(inputfiles) > settings.MAX_FILEUPLOADS_PER_INPUT:
too_many_files_msg = 'Submission aborted! Maximum %d files may be submitted at once' %\
settings.MAX_FILEUPLOADS_PER_INPUT
return HttpResponse(json.dumps({'success': too_many_files_msg}))
for inputfile in inputfiles:
if inputfile.size > settings.STUDENT_FILEUPLOAD_MAX_SIZE: # Bytes
file_too_big_msg = 'Submission aborted! Your file "%s" is too large (max size: %d MB)' %\
......
......@@ -144,6 +144,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
)
STUDENT_FILEUPLOAD_MAX_SIZE = 4*1000*1000 # 4 MB
MAX_FILEUPLOADS_PER_INPUT = 10
# FIXME:
# We should have separate S3 staged URLs in case we need to make changes to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment