示例#1
0
    def upload_file(self, files):
        """
		POST only, validates email during registration
		"""
        ufs = []
        for name, value in files.items():
            up = UploadedFile(symbol=name[1],
                              user_id=self.user_id,
                              file=value,
                              type_enum=UploadedFile.UploadedFileChoices(
                                  name[0]))
            up.save()
            ufs.append(up.id)
        return ufs
示例#2
0
文件: views.py 项目: ruankranz/pychat
def upload_file(request):
    """
	POST only, validates email during registration
	"""
    logger.debug('Uploading file %s', request.POST)
    res = []
    for file in request.FILES:
        uf = UploadedFile(symbol=file[1],
                          user=request.user,
                          file=request.FILES[file],
                          type_enum=UploadedFile.UploadedFileChoices(file[0]))
        uf.save()
        res.append(uf.id)
    return HttpResponse(json.dumps(res), content_type='application/json')
示例#3
0
    def upload_file(self, files):
        """
		POST only, validates email during registration
		"""
        ufs = {}
        for name, value in files.items():
            up = UploadedFile(symbol=name[1],
                              user_id=self.user_id,
                              file=value,
                              type_enum=UploadedFile.UploadedFileChoices(
                                  name[0]))
            up.save()
            res = ufs.setdefault(name[1], {})
            if name[0] == 'p':
                res['previewFileId'] = up.id
            else:
                res['fileId'] = up.id
        return ufs