def _filer_file_from_upload(model, request, path, upload_data, sha1=None):
 if sha1:
  upload = model.objects.filter(sha1=sha1).first()
  if upload:
   return upload
 file_form_cls = modelform_factory(model=model, fields=('original_filename', 'owner', 'file'))
 upload_form = file_form_cls(data={'original_filename': upload_data.name, 'owner': (request.user.pk if (request and (not request.user.is_anonymous())) else None)}, files={'file': upload_data})
 upload = upload_form.save(commit=False)
 upload.is_public = True
 if isinstance(path, Folder):
  upload.folder = path
 else:
  upload.folder = filer_folder_from_path(path)
 upload.save()
 return upload

def _filer_file_from_upload ( model , request , path , upload_data , sha1 = None ) : if sha1 : upload = model . objects . filter ( sha1 = sha1 ) . first ( ) if upload : return upload file_form_cls = modelform_factory ( model = model , fields = ( 'original_filename' , 'owner' , 'file' ) ) upload_form = file_form_cls ( data = { 'original_filename' : upload_data . name , 'owner' : ( request . user . pk if ( request and ( not request . user . is_anonymous ( ) ) ) else None ) } , files = { 'file' : upload_data } ) upload = upload_form . save ( commit = False ) upload . is_public = True if isinstance ( path , Folder ) : upload . folder = path else : upload . folder = filer_folder_from_path ( path ) upload . save ( ) return upload
create some sort of filer file from the given upload data .