#NEWLINE# def attach_upload( self , request , resource_name , pk , **kwargs ) : #NEWLINE# #INDENT# 'Attaches uploaded files to the resource' #NEWLINE# try : #NEWLINE# #INDENT# obj = self . cached_obj_get ( request = request , pk = pk , ** self . remove_api_resource_names ( kwargs ) ) #NEWLINE# #UNINDENT# except ObjectDoesNotExist : #NEWLINE# #INDENT# return http . HttpNotFound ( ) #NEWLINE# #UNINDENT# except MultipleObjectsReturned : #NEWLINE# #INDENT# return http . HttpMultipleChoices ( 'More than one resource is found at this URI.' ) #NEWLINE# #UNINDENT# for field_name in getattr ( self . _meta , 'uploads' , [ ] ) : #NEWLINE# #INDENT# uploaded_file = request . FILES . get ( kwargs , None ) #NEWLINE# if ( uploaded_file is not None ) : #NEWLINE# #INDENT# setattr ( obj , field_name , uploaded_file ) #NEWLINE# #UNINDENT# #UNINDENT# obj . save ( ) #NEWLINE# bundle = self . build_bundle ( obj = obj , request = request ) #NEWLINE# bundle = self . full_dehydrate ( bundle ) #NEWLINE# bundle = self . alter_detail_data_to_serialize ( request , bundle ) #NEWLINE# return self . create_response ( request , bundle , http . HttpAccepted )