Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3153 มุมมอง

Hi, I try to encode a large file but the below method gives me an error:

with open("/tmp/pdf/pdffiles.zip", "rb") as f:

binary_file = f.read()

encoded = base64.b64encode(binary_file)


self.download_zip = encoded


I tried to encode it chunk buy chunk but the downloded file is damaged:


zipfile = open("/tmp/pdf/pdffiles.zip", "rb")

encoded = False

while True:

chunk = zipfile.read(8192) 

if not chunk:

break

if encoded:

encoded += base64.b64encode(chunk)

else:

encoded = base64.b64encode(chunk)

zipfile.close()

self.download_zip = encoded 


Any hint how can I handle with large binary files?

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ส.ค. 20
3947
Odoo Mail Sending Limit แก้ไขแล้ว
2
ธ.ค. 23
14711
0
ต.ค. 23
33
3
ต.ค. 23
788
1
ต.ค. 23
569