我在向托管在 heroku 上的 django 应用程序发帖时遇到问题。我有一个提交 3 张图像的表单,当我使用大约 100kb 的较小图像时一切正常,但是当我使用 ~3MB 的较大图像时,上传失败并在 heroku 日志中显示为错误at=error code=H13 desc="Connection closed without response" method=POST path="/"
在 django 中,我只是保存图像然后通过电子邮件发送它们,如下所示,其中 formdata 保存图像。希望这个片段足够了:
for each in form_data:
pic = form_data[each]
if pic:
filename = os.path.join(self.location,f"{i} - {pic.name}")
imgbytes = pic.read()
with open(filename, 'wb+') as destination:
destination.write(imgbytes)
i+=1
fileholder.append(filename)
email = EmailMessage(
subject = 'Hello',
body = 'Body goes here',
from_email = 'example@yahoo.com',
to = ['test@google.com'],
)
for each in fileholder:
email.attach_file(each)
email.attach_file(newpath)
email.send()
是什么原因造成的,我如何确保成功上传任何尺寸的图像?
Cats萌萌
慕码人2483693
12345678_0001
相关分类