I have a flask application that allows users to upload and download files.
However, once a file has been uploaded, I would like for there to be a button that allows them to open that file, but in the browser, as you can with local files.
I created the button and linked it to the script below:
Here's what I've tried:
@app.route('/openFileInBrowser/<filename>')
def openFileInBrowser(filename):
    bucket = 'testBucket'
    s3_client = boto3.client('s3')
    presigned_url = s3_client.generate_presigned_url('get_object', Params = {'Bucket':
    bucket, 'Key': filename}, ExpiresIn = 3600)
    return presigned_url
However, all this did was redirect to a webpage with the presigned_url written on it.
Update:
I am now able to redirect to the presigned_url using return redirect(presigned_url, code=302). However, for files like PDF and TXT, instead of viewing them in the browser, it downloads the file. How am I able to make it so it opens the file in their browser instead?
 
    