此脚本将文件保存为"/home/name/main/all my files and stuff"
. 我想将其另存为"main/all my files and stuff"
.
def zipit ():
file_paths = ['/home/name/main/']
buffer= StringIO.StringIO()
z= zipfile.ZipFile( buffer, "w" )
for p in file_paths:
for dir, subdirs, files in os.walk(p):
for f in files:
z.write(os.path.join(dir, f))
z.close()
buffer.seek(0)
final = HttpResponse(buffer.read())
final['Content-Disposition'] = 'attachment; filename=dbs_custom_library.zip'
final['Content-Type'] = 'application/x-zip'
return final