Skip to content

Commit bcd56d7

Browse files
Merge pull request #213 from sendgrid/inbound-parse-compatibility
Python 2/3 compatibility, naming consistency
2 parents a7d2faf + 5095a8e commit bcd56d7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ install:
1010
- python setup.py install
1111
- pip install pyyaml
1212
- pip install flask
13+
- pip install six
1314
before_script:
1415
- mkdir prism
1516
- mkdir prism/bin

sendgrid/helpers/inbound/parse.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import base64
33
import email
44
import mimetypes
5+
from six import iteritems
56
from werkzeug.utils import secure_filename
67

78

@@ -47,7 +48,7 @@ def attachments(self):
4748

4849
def _get_attachments(self, request):
4950
attachments = []
50-
for _, filestorage in request.files.iteritems():
51+
for _, filestorage in iteritems(request.files):
5152
attachment = {}
5253
if filestorage.filename not in (None, 'fdopen', '<fdopen>'):
5354
filename = secure_filename(filestorage.filename)
@@ -72,7 +73,7 @@ def _get_attachments_raw(self, raw_email):
7273
filename = 'part-%03d%s' % (counter, ext)
7374
counter += 1
7475
attachment['type'] = part.get_content_type()
75-
attachment['filename'] = filename
76+
attachment['file_name'] = filename
7677
attachment['contents'] = part.get_payload(decode=False)
7778
attachments.append(attachment)
7879
return attachments

0 commit comments

Comments
 (0)