This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with tempfile.TemporaryDirectory() as workdir: | |
project_dirname = "project" | |
project_dir = os.path.join(workdir, project_dirname) | |
os.mkdir(project_dir) | |
# do esoteric work within that temporary workdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import tempfile | |
s3_bucket = "..." | |
s3_path = "..." | |
s3 = boto3.resource('s3', region_name='eu-west-1') | |
with tempfile.NamedTemporaryFile() as downloaded_file: | |
s3.Object(s3_bucket, s3_path).download_file(downloaded_file.name) | |
# continue processing downloaded_file |
OlderNewer