Skip to content

Commit

Permalink
Merge pull request #213 from sendgrid/inbound-parse-compatibility
Browse files Browse the repository at this point in the history
Python 2/3 compatibility, naming consistency
  • Loading branch information
thinkingserious authored Sep 1, 2016
2 parents a7d2faf + 5095a8e commit bcd56d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ install:
- python setup.py install
- pip install pyyaml
- pip install flask
- pip install six
before_script:
- mkdir prism
- mkdir prism/bin
Expand Down
5 changes: 3 additions & 2 deletions sendgrid/helpers/inbound/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import base64
import email
import mimetypes
from six import iteritems
from werkzeug.utils import secure_filename


Expand Down Expand Up @@ -47,7 +48,7 @@ def attachments(self):

def _get_attachments(self, request):
attachments = []
for _, filestorage in request.files.iteritems():
for _, filestorage in iteritems(request.files):
attachment = {}
if filestorage.filename not in (None, 'fdopen', '<fdopen>'):
filename = secure_filename(filestorage.filename)
Expand All @@ -72,7 +73,7 @@ def _get_attachments_raw(self, raw_email):
filename = 'part-%03d%s' % (counter, ext)
counter += 1
attachment['type'] = part.get_content_type()
attachment['filename'] = filename
attachment['file_name'] = filename
attachment['contents'] = part.get_payload(decode=False)
attachments.append(attachment)
return attachments
Expand Down

0 comments on commit bcd56d7

Please sign in to comment.