AWS S3 download file from Flask
<p>I have created a small app that should download file from a AWS S3. </p>

<p>I can download the data correctly in this way:</p>

<pre><code> s3_client = boto3.resource('s3')
 req = s3_client.meta.client.download_file(bucket, ob_key, dest)
</code></pre>

<p>but if I add this function in a flask route it does not work anymore. I obtain this error:</p>

<p>ClientError: An error occurred (400) when calling the HeadObject operation: Bad Request</p>

<p>I'm not able to figure out why it does not work inside the route. Any idea?</p>

<p>That is related to your AWS region. Mention the region name as an added parameter.</p>

<p>Try it on your local machine, using </p>

<pre><code>aws s3 cp s3://bucket-name/file.png file.png --region us-east-1
</code></pre>

<p>If you are able to download the file using this command, then it should work fine from your API also.</p>

python amazon-s3 flask boto3