Google App Engine의 Python 구현을 사용하고 있습니다. html 형식의 이미지 입력 태그 배열을 전달하려고하면 파이썬 컨트롤러에서 가져올 수 없습니다.Html 폼 이미지 배열을 Google App Engine (Python)에 전달하려면 어떻게해야합니까?
html로 :
<form action="/addImages" method="post" enctype="multipart/form-data">
<input type="file" name="images" />
<input type="file" name="images" />
<input type="file" name="images" />
</form>
파이썬 :
class AddImages(webapp.RequestHandler):
def post(self):
images = self.request.get_all('images')
for img in images:
if img != None:
img_entity.blob = db.Blob(img)
self.response.out.write("Upload Succeeded")
내가 이것을 할 때, 나는 지칠대로 지친 유니 코드/STR 오류 얻을 :
TypeError: Blob() argument should be str instance, not unicode
에서을 행 :
db.Blob(img)
대부분의 자습서를 따랐지만 그 중 어떤 것도이 특정 문제를 논의한 것 같지 않았습니다.
'db.Blob()'에서'img.encode()'를 시도 했습니까? – agf
유니 코드를 utf-8 또는 ascii로 인코딩 할 수 있지만 파일 데이터 중 일부를 삭제하지 않겠습니까? – mienaikoe
모든 필드에서 10MB 이상의 데이터를 업로드하려고하면 너무 큰 요청을 처리하게 될 것입니다. 맞습니까? BlobStore를 사용하는 것이 좋습니다. 이 두통이 사라집니다. – Paddy