15

I have a script that compresses the output files. The problem is that one of the files is over 4Gigs. How would I convert my script to use ZIP64 extensions instead of the standard zip?

Here is how I am currently zipping:

try:
    import zlib
    compression = zipfile.ZIP_DEFLATED
except:
    compression = zipfile.ZIP_STORED

modes = { zipfile.ZIP_DEFLATED: 'deflated',
          zipfile.ZIP_STORED:   'stored',
          } 

compressed_name = 'edw_files_' + datetime.strftime(date(), '%Y%m%d') + '.zip' 
print 'creating archive'
zf = zipfile.ZipFile('edw_files_' + datetime.strftime(date(), '%Y%m%d') + '.zip', mode='w')
try:
    zf.write(name1, compress_type=compression)
    zf.write(name2, compress_type=compression)
    zf.write(name3, compress_type=compression)
finally:
    print 'closing'
    zf.close()
Dharman
  • 30,962
  • 25
  • 85
  • 135
txwylde
  • 151
  • 1
  • 1
  • 4

2 Answers2

20

Check out zipfile-objects.

You can do this:

zf = zipfile.ZipFile('edw_files_' + datetime.strftime(date(), '%Y%m%d') + '.zip', mode='w', allowZip64 = True)
Abdul Fatir
  • 6,159
  • 5
  • 31
  • 58
Oladayo Oyelade
  • 225
  • 2
  • 9
9

Like this:

zf = zipfile.ZipFile('edw_files_' + datetime.strftime(date(), '%Y%m%d') + '.zip', mode='w', allowZip64=True)
MrAlexBailey
  • 5,219
  • 19
  • 30