async def _file_to_mxc_url(self, file_event): """Given a file event, return the mxc URL.""" uploaded = False mxc_url = None file_dict = None if file_event.url: url = urlparse(file_event.url) if url.scheme == "mxc": mxc_url = file_event.url if not mxc_url: encrypt_file = ( self._allow_encryption and file_event.target in self.connection.store.load_encrypted_rooms() ) upload_file = await file_event.get_file_bytes() mimetype = await file_event.get_mimetype() response = await self.connection.upload( lambda x, y: upload_file, content_type=mimetype, encrypt=encrypt_file ) if len(response) >= 2: response, file_dict = response else: response = None file_dict = None