Take a file input via URL?
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:{
  "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!
2023-02-10T18:00:38Z
Solved - I was able to use a Base64 encoding API to send the file in the format the Gradio Space was expecting.
2023-02-28T19:40:11Z
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.
2023-02-28T20:42:28Z
I was sending my file from aBubble.ioapp. 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 | Base64This base64 encoded version of your file is what huggingface expects when you have a space that needs files as an input.
2023-03-01T12:45:49Z
Okay. Thanks.