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
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')
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