def _upload_or_replace_fb(self,directory,fn,_album_id,\
            _megapixels=None,resize_request=None,movealbum_request=None,\
            changetitle_request=None,_title=None):
        """Does the actual upload to fb.
        if resize_request, will resize picture only if
        it already exists and the geometry on fb doesn't match
        what we want,
        returns (status)"""
        # We should check here if 
        db=self._loadDB(directory)

        # If resize request, make tempfile and
        # resize.
        if _megapixels:
            fp = tempfile.NamedTemporaryFile()
            fullfile_resized=fp.name
            logger.debug("tempfile for resized is %s"%(fp.name))

        fullfile=os.path.join(directory,fn)

        # If JPEG, then resize
        ext=os.path.splitext(fullfile)[1].lower()
        if ext=='.jpg':
            isJPG=True
        else:
            isJPG=False

        # If already in DB, remove first, then overwrite
        if fn in db:
            pid=db[fn]['photoid']
            if resize_request and isJPG:
                logger.info("fb: Resize request for %s",fn)
                if self._already_resized_on_fb(fullfile,pid,_megapixels):
                    logger.debug("%s - Already in DB and resized, skipping",fn)
                    return True
            elif movealbum_request:
                logger.info("fb: Move album request for %s",fn)
                if self._already_in_album(fullfile,pid,_album_id):
                    logger.debug("%s - Already in DB and in correct album, skipping",fn)
                    return True
            elif changetitle_request:
                logger.info("fb: Change title request for %s",fn)
                if self._title_uptodate(fullfile,pid,_title):
                    logger.debug("%s - Already in DB and title up to date, skipping",fn)
                    return True


            # --- If we are here it means photo should be updated.
            # With FB graph API this means removing the photo
            # and uploading with new meta data.
            logger.debug("%s - Already in DB, removing first",fn)
            if not self._remove_media(directory,fn):
                logger.error("%s - fb: couldn't replace (remove) file\n",fn)
                return False

        # Do we have to resize?
        if _megapixels and isJPG:
            if pusher_utils.resize_image(fullfile,fullfile_resized,_megapixels):
                logger.debug("%s resized to %s successfully"\
                        %(fullfile,fullfile_resized))
                fullfile=fullfile_resized
            else:
                logger.warning("%s couldn't resize, uploading original"\
                        %(fullfile))

        logger.debug("Upload %s to fb, album=%s, title='%s'",\
                fn,_album_id,_title)

        # We can get a place id by doing a search
        # http://graph.facebook.com/search?type=city&center=37,-122&distance=1000

        # Do the actual upload
        resp=self.fb.put_photo(open(fullfile),\
                message=_title,album_id=_album_id,\
                )
                #place='106377336067638'\

        logger.debug("%s - Upload response is : %s"%(fn,resp))

        if not resp.has_key('id'):
            print("%s - fb: upload failed", fn)
            return False

        pid=resp['id']
        db[fn]={}
        db[fn]['photoid']=pid
        logger.debug("%s - fb: uploaded with photoid %s",fn,pid);

        self._saveDB(directory,db)
        return True