Repository: gradio-app/gradio

Issue:
Download button does not respect the filepath returned by the function
### Describe the bug

In the `zip_two_files` demo:

```python
import os
from zipfile import ZipFile

import gradio as gr


def zip_two_files(file1, file2):
    with ZipFile("tmp.zip", "w") as zipObj:
        zipObj.write(file1.name, "file1")
        zipObj.write(file2.name, "file2")
    return "tmp.zip"


demo = gr.Interface(
    zip_two_files,
    ["file", "file"],
    "file",
    examples=[
        [os.path.join(os.path.dirname(__file__),"files/titanic.csv"), 
         os.path.join(os.path.dirname(__file__),"files/titanic.csv")],
    ],
)

if __name__ == "__main__":
    demo.launch()
```

When you download the file, it is renamed `download.zip` by default on Chrome.

### Download version 3.0.22
![file_download_bug](https://user-images.githubusercontent.com/41651716/176975733-1acf0dc9-2d65-4ac0-a56a-8a35d06218a0.gif)

That's not the case on version 3.0.12. The file is called `tmp` because that's what the prediction function returns. You can see the same behavior on this space: https://huggingface.co/spaces/radames/dpt-depth-estimation-3d-obj Was this change intentional?

### Download version 3.0.12
![file_download_correct](https://user-images.githubusercontent.com/41651716/176975756-758d94a3-6686-473a-9d07-72af220172e9.gif)



### Is there an existing issue for this?

- [X] I have searched the existing issues

### Reproduction

Run the `zip_two_files` demo on 3.0.22 and download the file.

### Screenshot

_No response_

### Logs

```shell
-
```


### System Info

```shell
3.0.22
```


### Severity

annoying


Discussion:
Thank you for addressing the bug @freddyaboulton. This came as my output is a mesh file (file.msh) and when I try to download the file it losses the .msh extension.
Thank you for bringing it to our attention! 
Any updates on this?
@irfan-mekic Thanks for the follow-up! 

We were working on improving the docs the last two weeks. Next we're working on the 3.2 milestone which will focus on bug fixes. I've added this issue to that milestone so someone will take a look at this soon.
Reopening as this seems to have come back as a results of #1967 

Resolving patch:
diff --git a/gradio/components.py b/gradio/components.py
--- a/gradio/components.py
+++ b/gradio/components.py
@@ -2006,7 +2006,7 @@ def __init__(
         Parameters:
             value: Default file to display, given as str file path. If callable, the function will be called whenever the app loads to set the initial value of the component.
             file_count: if single, allows user to upload one file. If "multiple", user uploads multiple files. If "directory", user uploads all files in selected directory. Return type will be list for each file in case of "multiple" or "directory".
-            type: Type of value to be returned by component. "file" returns a temporary file object whose path can be retrieved by file_obj.name, "binary" returns an bytes object.
+            type: Type of value to be returned by component. "file" returns a temporary file object whose path can be retrieved by file_obj.name and original filename can be retrieved with file_obj.orig_name, "binary" returns an bytes object.
             label: component name in interface.
             show_label: if True, will display label.
             interactive: if True, will allow users to upload a file; if False, can only be used to display files. If not provided, this is inferred based on whether the component is used as an input or output.
@@ -2071,11 +2071,14 @@ def process_single_file(f):
             )
             if self.type == "file":
                 if is_file:
-                    return processing_utils.create_tmp_copy_of_file(file_name)
+                    file = processing_utils.create_tmp_copy_of_file(file_name)
+                    file.orig_name = file_name
                 else:
-                    return processing_utils.decode_base64_to_file(
+                    file = processing_utils.decode_base64_to_file(
                         data, file_path=file_name
                     )
+                    file.orig_name = file_name
+                return file
             elif self.type == "bytes":
                 if is_file:
                     with open(file_name, "rb") as file_data:
@@ -2114,6 +2117,7 @@ def postprocess(self, y: str) -> Dict:
         if isinstance(y, list):
             return [
                 {
+                    "orig_name": os.path.basename(file),
                     "name": processing_utils.create_tmp_copy_of_file(
                         file, self.temp_dir
                     ).name,
@@ -2125,6 +2129,7 @@ def postprocess(self, y: str) -> Dict:
             ]
         else:
             return {
+                "orig_name": os.path.basename(y),
                 "name": processing_utils.create_tmp_copy_of_file(
                     y, dir=self.temp_dir
                 ).name,


Test patch:
diff --git a/test/test_components.py b/test/test_components.py
--- a/test/test_components.py
+++ b/test/test_components.py
@@ -854,6 +854,7 @@ def test_component_functions(self):
             file_input.serialize("test/test_files/sample_file.pdf")["name"],
             "test/test_files/sample_file.pdf",
         )
+        assert output.orig_name == "test/test_files/sample_file.pdf"
 
         self.assertIsInstance(file_input.generate_sample(), dict)
         file_input = gr.File(label="Upload Your File")