Python Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Python Examples

Quick Start
Python Unicode
Python Byte Array
Python Certs
Python Email
Python Encryption
Python FTP
HTML-to-XML
Python HTTP
Python IMAP
Python MHT
Python MIME
Python RSA
Python S/MIME
Python Signatures
Python Socket
Python Spider
Python Tar
Python Upload
Python XML
Python XMP
Python Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

Write Zip to Memory

Demonstrates how to write a zip into memory and then use it as input for other programming tasks.

Download Python Programming Example Scripts

# file: ZipToMemory.py

import chilkat

# Zip a directory tree, but instead of creating a .zip file,
# write the zip to a buffer in memory.
zip = chilkat.CkZip()
zip.UnlockComponent("anything for 30-day trial")

zip.NewZip("exampleData.zip")
zip.AppendFiles("exampleData/*",True)

zipFileImage = chilkat.CkByteData()
zip.WriteToMemory(zipFileImage)

# What's the point of this?
# Other Chilkat components can work with CkByteData objects.
# For example, we could add the Zip to a MIME message...
mime = chilkat.CkMime()
mime.UnlockComponent("Anything for 30-day trial")
mime.put_ContentType("application/zip")
mime.SetBodyFromBinary(zipFileImage)
mime.SaveMime("mime.txt")

# Or.. you could upload the zip file to
# an FTP server without ever having to write
# an actual .zip on the local filesystem...
ftp = chilkat.CkFtp2()
ftp.UnlockComponent("anything for 30-day trial")
ftp.put_Hostname("www.chilkatsoft.com")
ftp.put_Username("myLogin")
ftp.put_Password("myPassword")
success = ftp.Connect()
if success:
	ftp.ChangeRemoteDir("d2")
	remoteFilename = "myZip.zip"
	success = ftp.PutFileFromBinaryData(remoteFilename,zipFileImage)
	if success:
		print "Uploaded Zip to FTP server!\n"
	else:
		ftp.SaveLastError("ftpPutError.txt")
else:
	ftp.SaveLastError("ftpError.txt")






 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.