예제 #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