fixed 500 error for attachments closes #62
This commit is contained in:
parent
b821441580
commit
45f26932ee
|
@ -54,6 +54,12 @@ class CustomHandler:
|
|||
else:
|
||||
filename = part.get_filename()
|
||||
cid = part.get('Content-ID')
|
||||
if cid is not None:
|
||||
cid = cid[1:-1]
|
||||
elif part.get('Content-ID') is not None:
|
||||
cid = part.get('Content-ID')
|
||||
else:
|
||||
cid = str(uuid.uuid4())
|
||||
logger.debug('Handling attachment: "%s" of type "%s" with CID "%s"',filename, part.get_content_type(), cid)
|
||||
if filename is None:
|
||||
filename = 'untitled'
|
||||
|
@ -106,7 +112,7 @@ class CustomHandler:
|
|||
edata["attachments"].append(filenamebase+"-"+attd[0])
|
||||
edata["attachments_details"].append({
|
||||
"filename":attd[0],
|
||||
"cid":attd[2][1:-1],
|
||||
"cid":attd[2],
|
||||
"id":filenamebase+"-"+attd[0],
|
||||
"download_url":URL+"/api/attachment/"+em+"/"+filenamebase+"-"+attd[0],
|
||||
"size":len(attd[1])
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
EHLO example.com
|
||||
MAIL FROM: <sender@example.com>
|
||||
RCPT TO: <recipient@example.com>
|
||||
DATA
|
||||
From: me <me@example.org>
|
||||
To: you <recipient@example.net>
|
||||
Subject: MIME encapsulation demo
|
||||
Mime-Version: 1.0
|
||||
Content-type: multipart/alternative; boundary="covfefe"
|
||||
|
||||
--covfefe
|
||||
Content-type: text/plain; charset="utf-8"
|
||||
Content-transfer-encoding: quoted-printable
|
||||
|
||||
You had me at "H=
|
||||
ello."
|
||||
|
||||
--covfefe
|
||||
Content-type: text/html; charset="utf-8"
|
||||
Content-transfer-encoding: base64
|
||||
|
||||
PGh0bWw+PGhlYWQ+PHRpdGxlPkhlbGxvLCBpcyBpdCBtZSB5b3UncmUgbG9va2luZyBmb3I/PC
|
||||
90aXRsZT48L2hlYWQ+PGJvZHk+PHA+VGhlIGNvdiBpbiB0aGUgZmUgZmU8L3A+PC9ib2R5Pjwv
|
||||
aHRtbD4K
|
||||
|
||||
--covfefe--
|
||||
|
||||
.
|
||||
|
||||
QUIT
|
Loading…
Reference in New Issue