def _upload_media(self,directory,files=None,resize_request=None,movealbum_request=None,changetitle_request=None):
<EOL>if not self._connectToFB():<EOL><INDENT>logger.error("<STR_LIT>")<EOL>return False<EOL><DEDENT>_megapixels=self._load_megapixels(directory)<EOL>_album_id,_album_name=self._get_album(directory)<EOL>if not _megapixels:<EOL><INDENT>mpstring="<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>mpstring=("<STR_LIT>"%(_megapixels))<EOL><DEDENT>if not files:<EOL><INDENT>db=self._loadDB(directory)<EOL>files=list(db.keys())<EOL><DEDENT>if isinstance(files,str):<EOL><INDENT>files=[files]<EOL><DEDENT>files.sort()<EOL>for filename in files:<EOL><INDENT>title=self._get_title(directory,filename)<EOL>if title:<EOL><INDENT>print(("<STR_LIT>"%(filename,_album_name,mpstring,title)))<EOL><DEDENT>else:<EOL><INDENT>print(("<STR_LIT>"%(filename,_album_name,mpstring)))<EOL><DEDENT>status=self._upload_or_replace_fb(directory,filename,_album_id, _megapixels,resize_request,movealbum_request,changetitle_request,title)<EOL>if not status:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL>
Uploads media file to FB, returns True if
        uploaded successfully, Will replace 
        if already uploaded, If megapixels > 0, will
        scale photos before upload
        If no filename given, will go through all files in DB