Home > Blockchain >  How to download files onto personal computer from EC2 without knowing file name?
How to download files onto personal computer from EC2 without knowing file name?

Time:10-18

I want to use selenium to log into a private database and download some files. I can already do this via a python script that will launch a new chrome window (via selenium) and automatically download the files I need locally.

My python script uses selenium. Once the python script is run, it launches a google chrome window, which selenium then does some automatic clicking on to download files.

Now, I want to deploy my code to a web application so that I have a website online for others to use. I have my script on an Amazon EC2 instance and I call/invoke my script whenever a user on my website clicks a button. However, the files are downloaded onto the EC2 instance. I need these files to be downloaded on the person's personal computer after he clicks my button on my website.

Is there a way to achieve this, either by re-directing downloads? The file names are not known at runtime.

In summary, I have a script (which downloads files) on EC2 that is invoked when my button on my website is clicked. But I need the downloaded files to go onto the user's computer, not the EC2 instance/terminal.

Thank you in advance!

CodePudding user response:

However, the files are downloaded onto the EC2 instance. I need these files to be downloaded on the person's personal computer

No there is no way to redirect downloads from an EC2 instance in the same way that you can't redirect downloads normally outside of AWS anyway.

When you download a file, you download it to the machine that requests the download.

Perhaps try returning the download URL in some way back to the UI and trigger the download yourself on the machine (if the URL does not need credentials). Or download the file, reupload to S3 and create a pre-signed URL that you can return to the UI.

  • Related