Welcome to the Xceed Community | Help
Community Search  
More Search Options

Self extracting zip from blobs in db

Sort Posts: Previous Next
  •  04-18-2008, 2:29 PM Post no. 11600

    Self extracting zip from blobs in db

    Hi,

    I'm trying to make one self extracting zip file from many files stored as blobs in Oracle.
    I want to avoid saving the files to to disk and just stream them into the self extracting zip.

    I've looked at examples making use of the self extracting zips.
    I've looked at examples using compressed streams.

    But I can't seam to figure out how to steam the blobs into the self extracting zip.
    I'm thinking I'm trying to do something that is not supported in xceed.

    Is there a solution to this other than saving the files to disk first?

    Filed under:
  •  04-22-2008, 3:49 PM Post no. 11661 in reply to 11600

    Re: Self extracting zip from blobs in db

    Using the ZippedFile class, you can bypass the "on disk" part.

    In this example, let's say I have a stream on each of the blobs (represented by the stream on each of the files from my TestFolder). Also, my self-extractor file is on disk, but it could be a MemoryFile. As for the name of the file, I gave them random names, but I could have used some file specific names instead. 

    private static void StreamedFilesToSFXForum11600()
    {
      Xceed.Zip.Licenser.LicenseKey = "license key";
      AbstractFile[] files = new DiskFolder( @"D:\TestFolder" ).GetFiles( true, null );

      AbstractFile sfxFile = new DiskFile( @"D:\Forum11600\archive.exe" );
      ZipArchive archive = new ZipArchive( sfxFile );
      XceedSfxPrefix sfx = new XceedSfxPrefix( new DiskFile( @"C:\Program Files\Xceed Components\Bin\Sfx\XcdSfxZ64AES.bin" ) );
      archive.SfxPrefix = sfx;

      int counter = 0;
      archive.BeginUpdate();
      foreach( AbstractFile file in files )
      {
        using( Stream source = file.OpenRead() )
        {
          ZippedFile zipped = new ZippedFile( sfxFile, "Name" + counter.ToString() );
          zipped.Create();
          using( Stream destination = zipped.OpenWrite( true ) )
          {
            byte[] buffer = new byte[ 32768 ];
            int bytesRead = 0;
            while( ( bytesRead = source.Read( buffer, 0, buffer.Length ) ) > 0 )
            {
              destination.Write( buffer, 0, bytesRead );
            }
          }
        }
        counter++;
      }
      archive.EndUpdate();
    }


    Charles Bérubé-Rémillard
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.