在我们网站上下载文件后,我们会用它压缩自述文件和教程文件。下载一些文件后,我收到此错误:
Unable to expand "File.zip" into "Downloads"
以下代码。任何想法为什么这可能只发生在一些文件而不是其他文件?它可能与文件本身的内容有关吗?
if len(output_streams) > 1:
# If we have multiple files, then package them up since we can only return one
upload_name = file_key + '.zip'
# Create a new stream and write to it
write_stream = StringIO()
zip_file = ZipFile(write_stream, "a")
for ext_name, stream in output_streams.iteritems():
if '.' in ext_name:
zip_file.writestr(ext_name, stream.getvalue().encode('utf-8','ignore'))
else:
zip_file.writestr(file_key + '.' + ext_name, stream.getvalue().encode('utf-8','ignore'))
#adding the readme file
try:
if 'ManufacturerName' in manuf['manufacturer']:
zip_file.writestr('how-to-import.htm', "<script>window.location = 'https://www.example.com/manufacturer/';</script>")
else:
zip_file.writestr('how-to-import.htm', "<script>window.location = 'https://www.example.com/about/import/';</script>")
except:
zip_file.writestr('how-to-import.htm', "<script>window.location = 'https://www.example.com/about/import/';</script>")
zip_file.close()