Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Zip to Memory
Perl script to zip to a buffer in memory instead of a zip file. # file: ZipToMemory.pl use chilkat; # Zip a directory tree, but instead of creating a .zip file, # write the zip to a buffer in memory. $zip = new chilkat::CkZip(); $zip->UnlockComponent("anything for 30-day trial"); $zip->NewZip("exampleData.zip"); $zip->AppendFiles("exampleData/*",true); $zipFileImage = new 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 = new 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 = new 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) { printf("Uploaded Zip to FTP server!\n"); } else { $ftp->SaveLastError("ftpPutError.txt"); } } else { $ftp->SaveLastError("ftpError.txt"); } |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.