Gradio 用户月活突破一百万!

了解更多
Gradio logo
  1. 助手
  2. DownloadData

Gradio 新手?从这里开始: 入门指南

查看发布历史

DownloadData

gradio.DownloadData(···)

描述

gr.DownloadData 类是 gr.EventData 的子类,专门用于携带有关 .download() 事件的信息。当 gr.DownloadData 作为类型提示添加到事件监听器方法的参数时,gr.DownloadData 对象将自动作为该参数的值传递。此对象的属性包含有关触发监听器的事件的信息。

用法示例

import gradio as gr
def on_download(download_data: gr.DownloadData):
    return f"Downloaded file: {download_data.file.path}"
with gr.Blocks() as demo:
    files = gr.File()
    textbox = gr.Textbox()
    files.download(on_download, None, textbox)
demo.launch()

属性

参数
🔗
file: FileData

已下载的文件,以 FileData 对象形式呈现。