# Take a file input via URL?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftake-a-file-input-via-url%2F31413%3E%5C
**Category:** 🔒 Gradio\
**Created:** [February 10, 2023, 1:23am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftake-a-file-input-via-url%2F31413 "2023-02-10T01:23:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vamsi-tetali](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@vamsi-tetali](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvamsi-tetali)%5C
**Post date:** [February 10, 2023, 1:23am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftake-a-file-input-via-url%2F31413%2F1 "2023-02-10T01:23:01Z")

</div>

Hi,

I’ve been using the Gradio Spaces’ API functionality for a number of features in my app. I have a new space that takes an uploaded file as an input. The API documentation for this space expects the following in the request body:

```auto
{
  "data": [
     
{"name":"zip.zip","data":"data:@file/octet-stream;base64,UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA=="}
 : { name: string; data: string }, // represents file name and base64 data as an object of 'file' File component
  ]
}

```

I don’t understand how I should send this file input. As an alternative to this, I was wondering if it would be possible to send the S3 location of my file, its url, as an input instead of whatever I’ve pasted above. Does anyone know if this is possible and has anyone done something like this?

Thank you for any help/guidance you can provide!

---

<div class="post-metadata">

**Author:** ![vamsi-tetali](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@vamsi-tetali](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvamsi-tetali)%5C
**Post date:** [February 10, 2023, 6:00pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftake-a-file-input-via-url%2F31413%2F2 "2023-02-10T18:00:38Z")

</div>

Solved - I was able to use a Base64 encoding API to send the file in the format the Gradio Space was expecting.

---

<div class="post-metadata">

**Author:** ![nabeelraza](https://avatars.discourse-cdn.com/v4/letter/n/71e660/32.png) [@nabeelraza](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnabeelraza)%5C
**Post date:** [February 28, 2023, 7:40pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftake-a-file-input-via-url%2F31413%2F3 "2023-02-28T19:40:11Z")

</div>

Hi @vamsi-tetali, can you please share the details for this solution? Like, what API did you use and if you could provide a code snippet it would be a great help. I am stuck.

---

<div class="post-metadata">

**Author:** ![vamsi-tetali](https://avatars.discourse-cdn.com/v4/letter/v/c4cdca/32.png) [@vamsi-tetali](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvamsi-tetali)%5C
**Post date:** [February 28, 2023, 8:42pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftake-a-file-input-via-url%2F31413%2F4 "2023-02-28T20:42:28Z")

</div>

I was sending my file from a [Bubble.io](http://Bubble.io) app. Within the Bubble ecosystem, there is a plugin that can be used to encode a file into base64 and then send it to my huggingface space that requires a file input. In addition to the base64 encoded version of the file, my space also needs filename to be sent as a parameter. For that I simply sent the file’s name as a string.

Base64 encoding is a very common thing in many APIs (especially those related to email). If you are curious about what it means to encode your file as a base64 string, follow this link, upload your file, select “Data URI” as the “Output Format” and see the base64 encoded version of your file: [File to Base64 | Base64 Encode | Base64 Converter | Base64](https://base64.guru/converter/encode/file)

This base64 encoded version of your file is what huggingface expects when you have a space that needs files as an input.

---

<div class="post-metadata">

**Author:** ![nabeelraza](https://avatars.discourse-cdn.com/v4/letter/n/71e660/32.png) [@nabeelraza](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnabeelraza)%5C
**Post date:** [March 1, 2023, 12:45pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftake-a-file-input-via-url%2F31413%2F5 "2023-03-01T12:45:49Z")

</div>

Okay. Thanks.
