Skip to content

Commit

Permalink
Solving Miserlou#881 as in mbeacom
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-braun committed Jul 30, 2017
1 parent a21c973 commit 10f5508
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions zappa/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import datetime
import importlib
import inspect
import io
import json
import logging
import os
Expand Down Expand Up @@ -161,12 +162,14 @@ def load_remote_project_zip(self, project_zip_path):
remote_bucket, remote_file = parse_s3_url(project_zip_path)
s3 = boto_session.resource('s3')

zip_path = '/tmp/{0!s}'.format(remote_file)
s3.Object(remote_bucket, remote_file).download_file(zip_path)
zip_path = s3.Object(remote_bucket, remote_file)

# Unzip contents to project folder
with zipfile.ZipFile(zip_path, 'r') as z:
z.extractall(path=project_folder)
with io.BytesIO() as tf:
zip_path.download_fileobj(tf)
tf.seek(0) # Rewind the file
# Read zip contents and extract them to the project folder
with zipfile.ZipFile(tf, 'r') as z:
z.extractall(path=project_folder)

# Add to project path
sys.path.insert(0, project_folder)
Expand Down

0 comments on commit 10f5508

Please sign in to comment.