| Dart Home | PowerTCP Zip Compression for Active | Custom Development | Reply | PowerTCP Zip Compression for ActiveX Topics | Forums |
| Author | Forum: PowerTCP Zip Compression for ActiveX Topic: Using ZIP + FtpServer + DartStream in Memory |
| User142 Posts: 18 Member Since: 07/18/01 |
posted February 24, 2002 11:20 PM I'm using this code in the processing on the Retrieve event in the FtpServer control: // Create Zip CZip Zip; Zip.Create(ZIPTOOL_LICENSE); // Get file name if (Request->Parameters->Count>0) { _bstr_t filename = Request->Parameters->GetItem(&CComVariant(1)); // Add to Zip DartZip::IDartStreamPtr Data = Response->Data; _bstr_t filename2 = Data->FileName; Zip->FileStore->Add(filename2,VARIANT_FALSE,VARIANT_FALSE,_bstr_t(""),DartZip::zipNoEncryption); // Store to Dart Stream CComVariant dest = _T("C:\\temp.zip"); Zip->FileStore->Zip(dest,NULL); // Create DartStream DartFtpServer::IDartStreamPtr Stream; Stream.CreateInstance(DartZip::CLSID_DartStream); Stream->FileMode = DartFtpServer::createExisting; Stream->FileName = _T("C:\\temp.zip"); // Set dartstream to response Response->Data = Stream.Detach(); } I would have prefered not to store the ZIP compressed data temporarily on the hard disk but then I try this: // Create DartStream DartFtpServer::IDartStreamPtr Stream; Stream.CreateInstance(DartZip::CLSID_DartStream); // Create Zip CZip Zip; Zip.Create(ZIPTOOL_LICENSE); // Get file name if (Request->Parameters->Count>0) { _bstr_t filename = Request->Parameters->GetItem(&CComVariant(1)); // Add to Zip DartZip::IDartStreamPtr Data = Response->Data; _bstr_t filename2 = Data->FileName; Zip->FileStore->Add(filename2,VARIANT_FALSE,VARIANT_FALSE,_bstr_t(""),DartZip::zipNoEncryption); // Store to Dart Stream CComVariant dest = Stream; Zip->FileStore->Zip(dest,NULL); // Set dartstream to response Response->Data = Stream.Detach(); } I get a C++ exception 0x800a2efb. Please Note that I try to Zip() directly into a Stream object rather than a file name. This fails. HELP ??? Thanks |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted February 25, 2002 5:52 PM Hi Marc, We just released an update that fixed a problem with DartStreams and the Zip Tool. Please first try with those dlls: http://www.dart.com/downloads/update.exe Thanks, -ken K M Drake Dart Tech Support |
| User142 Posts: 18 Member Since: 07/18/01 |
posted February 25, 2002 6:17 PM Still there. Here's the call stack showing the exception triggered on the call to Zip(): KERNEL32! 77e989d1() MCSERVER! _CxxThrowException@8 + 57 bytes _com_error::_com_error(_com_error * const 0x00000000 {???}, long 0x800a2efb, IErrorInfo * 0x00150c68, unsigned char 0x68) address 0x004104eb _com_issue_errorex(long 0x800a2efb, IUnknown * 0x00150c68, const _GUID & {77A7F640-F620-77A7-F8F5-A77701000000}) + 93 bytes _com_issue_errorex(long 0x800a2efb, IUnknown * 0x013b1f38, const _GUID & {IID_IFileStore}) + 93 bytes DartZip::IFileStore::Zip(const _variant_t & {True VT_BOOL}, DartZip::ISpanSettings * 0x00000000) line 387 CZipFtpServer::OnRetrieve(CZipFtpServer * const 0x0012fea4, DartFtpServer::IRequest * 0x00fe3fd4, DartFtpServer::IResponse * 0x00fe211c) line 68 + 97 bytes OLEAUT32! DispCallFunc@32 + 349 bytes ATL::IDispEventSimpleImpl<0,CFtpServer,&DartFtpServer::DIID__IFtpServerEvents>::InvokeFromFuncInfo(void (void)* 0x00401235 [thunk]:`vcall'{88,{flat}}' , ATL::_ATL_FUNC_INFO & {...}, tagDISPPARAMS * 0x0012f494, tagVARIANT * 0x0012f484 {VT_EMPTY}) line 3753 + 51 bytes ATL::IDispEventSimpleImpl<0,CFtpServer,&DartFtpServer::DIID__IFtpServerEvents>::Invoke(ATL::IDispEventSimpleImpl<0,CFtpServer,&DartFtpServer::DIID__IFtpServerEvents> * const 0x0012fea4, long 0x0000000d, const _GUID & {00000000-0000-0000-0000-000000000000}, unsigned long 0x00000400, unsigned short 0x0001, tagDISPPARAMS * 0x0012f494, tagVARIANT * 0x0012f484 {VT_EMPTY}, ...) line 3728 DARTFTPSERVER! 00e61faf() ... DARTFTPSERVER! 00e59f28() OLEAUT32! DispCallFunc@32 + 349 bytes DARTFTPSERVER! 00e55864() ... USER32! 77e34553() ATL::CDialogImpl<CMainDlg,ATL::CWindow>::DoModal(HWND__ * 0x00000000, long 0x00000000) line 2336 + 37 bytes WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x0013281a, int 0x00000001) line 98 + 29 bytes WinMainCRTStartup() line 198 + 54 bytes KERNEL32! 77e8d326() |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted February 26, 2002 10:14 AM Hi, Below is VB code that works. During a retrieve, the server returns the file as a zipped file. What happens when you translate this code to VC? Thanks, -ken Dim unzippedStream As New DartStream Dim zippedStream As New DartStream ' Set Unzipped Stream = File's Data unzippedStream.Write Response.data.ReadString ' Add File's Data to FileStore Response.data.Position = 0 Zip1.FileStore.Clear Zip1.FileStore.add Response.data ' Zip File's Data into Zipped Stream Zip1.FileStore.Zip zippedStream ' Set Response = Zipped Stream Response.data.Clear Response.status = 150 Response.data = zippedStream Response.data.Position = 0 ' Reset File's Data on Server = Unzipped Stream unzippedStream.Position = 0 unzippedStream.FileName = rootDir & Request.Parameters.All K M Drake Dart Tech Support |
| User142 Posts: 18 Member Since: 07/18/01 |
posted February 26, 2002 9:40 PM I tried this: CZip Zip1; Zip1.Create(ZIPTOOL_LICENSE); // Dim unzippedStream As New DartStream DartFtpServer::IDartStreamPtr unzippedStream; unzippedStream.CreateInstance(DartZip::CLSID_DartStream); // Dim zippedStream As New DartStream DartFtpServer::IDartStreamPtr zippedStream; zippedStream.CreateInstance(DartZip::CLSID_DartStream); // Set Unzipped Stream = File's Data // unzippedStream.Write Response.data.ReadString _bstr_t srcString = Response->Data->ReadString(20); unzippedStream->Write(srcString,20); // Add File's Data to FileStore // Response.data.Position = 0 Response->Data->Position = 0; // Zip1.FileStore.Clear Zip1->FileStore->Clear(); // Zip1.FileStore.add Response.data CComVariant srcData = Response->Data; Zip1->FileStore->Add(srcData,VARIANT_FALSE,VARIANT_FALSE,_bstr_t(""),DartZip::zipNoEncryption); // Zip File's Data into Zipped Stream // Zip1.FileStore.Zip zippedStream CComVariant destData = zippedStream; Zip1->FileStore->Zip(destData,NULL); // Set Response = Zipped Stream // Response.data.Clear Response->Data->Clear(); // Response.status = 150 Response->Status = 150; // Response.data = zippedStream Response->Data = zippedStream; // Response.data.Position = 0 Response->Data->Position = 0; and I get a memory axception in Add(...) I tried to replace the call to Add() from using a DartStream to using a file name by changing this: _bstr_t srcData = Response->Data->FileName; Then I'm able to reach the call to Zip() but I get once again a C++ exception number thrown by COM because the return code from raw_Zip() is 0x800a2efb. I've also tried to comment out the uze of unzippedStream, didn't change a thing. Marc Ridey Info-Onscreen SOftware Systems |
K M Drake![]() From: Utica, NY USA Posts: 3406 Member Since: 07/14/00 |
posted February 27, 2002 10:06 AM Hi Marc, Please send your zipped simple project to support@dart.com, and we will take a look at it. Thanks, -ken K M Drake Dart Tech Support |
| User142 Posts: 18 Member Since: 07/18/01 |
posted March 6, 2002 9:45 PM This is a simplified code: int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Initialise ATL use HRESULT hRes = ::CoInitialize(NULL); hRes = _Module.Init(NULL, hInstance); // Create Zip control CZip Zip; Zip.Create(ZIPTOOL_LICENSE); // Create Stream object DartZip::IDartStreamPtr Stream; Stream.CreateInstance(DartZip::CLSID_DartStream); // Create memory buffer to load Stream LPBYTE buf = new BYTE[5000]; LPBYTE pos = buf; for (int i=0; i<5000; i++,pos++) *pos = i; // Create safearray SAFEARRAYBOUND rgsabound[1]; rgsabound[0].cElements = 5000; rgsabound[0].lLbound = 1; // Create an OLE SAFEARRAY SAFEARRAY *array; array = SafeArrayCreate(VT_UI1,1,rgsabound); // Load aray VARIANT var; if(array != NULL) { if (buf != NULL) { void * pArrayData = NULL; SafeArrayAccessData(array,&pArrayData); memcpy(pArrayData, buf, 5000); SafeArrayUnaccessData(array); } var.vt = VT_UI1 l VT_ARRAY; var.parray = array; } else { var.vt = VT_NULL; var.parray = NULL; } // Load buffer into stream Stream->Write(var,5000); // Load stream into Zip Control CComVariant buffer = Stream; Zip->FileStore->Add(buffer,VARIANT_TRUE,VARIANT_FALSE,_bstr_t(""),DartZip::zipNoEncryption); // Store Zip file on hard disk drive CComVariant dest = _T("c:\\darttest.zip"); Zip->FileStore->Zip(dest,NULL); // Clean memory delete buf; if (array) SafeArrayDestroy(array); // Terminate ATL use _Module.Term(); ::CoUninitialize(); return 0; } A sample project has been emailed. |
| User142 Posts: 18 Member Since: 07/18/01 |
posted March 7, 2002 6:05 PM Thanks to Tech support, here's the answer to the Add() Memory Exception violation. The call to Add() doesn't like the use of CComVariant. Replace the call to Add() in the sample in my last post with: VARIANT srcData; srcData.vt = VT_DISPATCH; srcData.punkVal= Stream; Zip->FileStore->Add(srcData,FALSE,FALSE,_bstr_t(""),DartZip::zipNoEncryption); That work's fine. |
| Reply | PowerTCP Zip Compression for ActiveX Topics | Forums |
This site is powered by
PowerTCP WebServer for ActiveX
|