I am having trouble doing a post to a django app hosted on heroku. I have a form that submits 3 images and everything works fine when I use smaller images of about 100kb, however when I user larger images of ~3MB the upload fails with error in heroku logs showing as at=error code=H13 desc="Connection closed without response" method=POST path="/"
In django, am simply saving the images then emailing them as shown below, where formdata is holding the images. Hope the snippet is enough:
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()
What is causing this and how can i ensure any image size is uploaded succesfully?