How to download a file in the server side

So bascially I have a jupyter notebook which acts as a server, I have a file upload component from which the user is going to upload their files, I want this file to get downloaded on the server side

I notice that i can get only the url,length,bytes from the file to the server, however i want the entire file itself

Code Sample:
Server code

import anvil.media
@anvil.server.callable
def download_file(file):
    #i want to download the file here ( the file is an mp4 audio file )

Anvil code

def file_loader_1_change(self, file, **event_args):
     anvil.server.call('download_file',file)

Clone link:
MeetingOWL

the variable file in your code snippets is a Media Object.

To convert a Media Object to a file you probably want this section of the docs:

3 Likes

Hello!!

I am trying to use an uploaded Excel file into my Server code through Uplink. Funny enough, my code looks exactly as OP’s in this case.

Can you please elaborate on your solution, I have read the documentation, and still running into issues of simply passing the file into my function.

Thank you for your time…

1 Like