def create_result(user, data, content=None, image=None): assert content or image data = get_data(user, did=data.id, write=False) if content: name = content.name else: name = image.name name = html.chop_dirname(name) mime = mimetypes.guess_type(name)[0] result = models.Result(data=data, name=name, mime=mime) result.store( content=content, image=image ) return result
def upload_processor(request, pid): "Handles the actual data upload" user = request.user if user.is_authenticated() and user.username!='public': if 'upload' in request.POST: count = 0 for i in range(50): # take at most 50 files key = 'File%s' % i if key in request.FILES: count += 1 stream = request.FILES[key] name = html.chop_dirname( stream.name ) logger.debug('%s uploaded file %s' % (user.username, name) ) authorize.create_data(user=user, pid=pid, stream=stream, name=name, info='no information') user.message_set.create(message="Uploaded %s files" % count) if 'simple' in request.POST: return html.redirect("/project/view/%s/" % pid) # this is needed only because the JUPload applet makes a HEAD request return html.response('SUCCESS\n')