async def async_move_files_to_cache(
    data: Any,
    block: Block,
    postprocess: bool = False,
    check_in_upload_folder=False,
    keep_in_cache=False,
) -> dict:
    """Move any files in `data` to cache and (optionally), adds URL prefixes (/file=...) needed to access the cached file.
    Also handles the case where the file is on an external Gradio app (/proxy=...).

    Runs after .postprocess() and before .preprocess().

    Args:
        data: The input or output data for a component. Can be a dictionary or a dataclass
        block: The component whose data is being processed
        postprocess: Whether its running from postprocessing
        check_in_upload_folder: If True, instead of moving the file to cache, checks if the file is in already in cache (exception if not).
        keep_in_cache: If True, the file will not be deleted from cache when the server is shut down.
    """

    def _mark_svg_as_safe(payload: FileData):
        # If the app has not launched, this path can be considered an "allowed path"
        # This is mainly so that svg files can be displayed inline for button/chatbot icons
        if (
            (blocks := LocalContext.blocks.get()) is None or not blocks.is_running
        ) and (mimetypes.guess_type(payload.path)[0] == "image/svg+xml"):
            utils.set_static_paths([payload.path])

    async def _move_to_cache(d: dict):
        payload = FileData(**d)
        # If the gradio app developer is returning a URL from
        # postprocess, it means the component can display a URL
        # without it being served from the gradio server
        # This makes it so that the URL is not downloaded and speeds up event processing
        if payload.url and postprocess and client_utils.is_http_url_like(payload.url):
            payload.path = payload.url
        elif utils.is_static_file(payload):
            pass
        elif not block.proxy_url:
            # If the file is on a remote server, do not move it to cache.
            if not client_utils.is_http_url_like(payload.path):
                _check_allowed(payload.path, check_in_upload_folder)
            if not payload.is_stream:
                temp_file_path = await block.async_move_resource_to_block_cache(
                    payload.path
                )
                if temp_file_path is None:
                    raise ValueError("Did not determine a file path for the resource.")
                payload.path = temp_file_path
                if keep_in_cache:
                    block.keep_in_cache.add(payload.path)

        url_prefix = (
            f"{API_PREFIX}/stream/" if payload.is_stream else f"{API_PREFIX}/file="
        )
        if block.proxy_url:
            proxy_url = block.proxy_url.rstrip("/")
            url = f"{API_PREFIX}/proxy={proxy_url}{url_prefix}{payload.path}"
        elif client_utils.is_http_url_like(payload.path) or payload.path.startswith(
            f"{url_prefix}"
        ):
            url = payload.path
        else:
            url = f"{url_prefix}{payload.path}"
        payload.url = url
        _mark_svg_as_safe(payload)
        return payload.model_dump()

    if isinstance(data, (GradioRootModel, GradioModel)):
        data = data.model_dump()
    return await client_utils.async_traverse(
        data, _move_to_cache, client_utils.is_file_obj_with_meta
    )
Move any files in `data` to cache and (optionally), adds URL prefixes (/file=...) needed to access the cached file.
    Also handles the case where the file is on an external Gradio app (/proxy=...).

    Runs after .postprocess() and before .preprocess().

    Args:
        data: The input or output data for a component. Can be a dictionary or a dataclass
        block: The component whose data is being processed
        postprocess: Whether its running from postprocessing
        check_in_upload_folder: If True, instead of moving the file to cache, checks if the file is in already in cache (exception if not).
        keep_in_cache: If True, the file will not be deleted from cache when the server is shut down.
    
gradio/processing_utils.py