The Download command silently downloads a specific version of an object store item and saves it to a specified file on the local machine. The client application must use either the IDownloadCmd or IDownloadCmd2 interface to specify the item to download and may optionally identify which content element to download using the index value. When initializing with the IDownloadCmd interface, the full pathname of the destination file must be supplied. However, only the destination directory must be provided when initializing with the IDownloadCmd2 interface, where the filename is subsequently extracted from the HTTP response headers attachment name.
After the Download command has been executed by calling IAppIntCmd::Invoke, a Download response component is returned. Client applications may interact with the response component via the standard IAppIntRsp and custom IDownloadRsp interfaces. For more information about working with command and response components and their COM interfaces, see Command and Response components.
NOTE The Download command does not perform any type of checkout command or invoke a graphical user interface, it simply downloads a specified item.
DLL | FnAppIntDownloadCmd.dll |
See Also | Upload, Open and SelectObject commands |
The Download command uses the following interfaces:
Interface | Description |
---|---|
IDownloadCmd |
This is a custom interface used to initialize the data contained in the Download command component. When initializing with the IDownloadCmd interface, the full pathname of the destination file must be supplied. The client application can use the methods in this interface to specify the object store item to download and identify which content element to download. |
IDownloadCmd2 |
This is a custom interface used to initialize the data contained in the Download command component. When initializing with the IDownloadCmd2 interface, only the destination directory must be provided; the filename is subsequently extracted from the HTTP response headers attachment name. The client application can use the methods in this interface to specify the object store item to download and identify which content element to download. |
IDownloadRsp |
This is a custom interface for the Download response component that is returned when the Download command is executed. This interface enables the client application to obtain the filename, path location, MIME type, and size (number of bytes) of the object store item that was downloaded. |
IAppIntCmd |
This is a standard interface which is automatically used by the Download command to invoke the Download command component. The client application executes the Download command by calling this interface and passing the AppIntSession component on which the Download command component is invoked. Each time the command is executed, an Download response component is returned. |
IAppIntRsp |
This is a standard interface that is automatically used by the Download command to determine the success or failure of the command, as well as retrieve any error code or messages. |
In the application's StdAfx.h header file:
#import"C:\Program Files\FileNet\AppInt\FnAppIntCmd.tlb" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntHttpRequest.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntBrowserDlg.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntHttpConnection.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntResources.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntClientRecordBase.tlb" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntClientStore.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntSession.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntSessionLogin.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntCmdComponents.dll" named_guids no_namespace
#import "C:\Program Files\FileNet\AppInt\FnAppIntDownloadCmd.dll" named_guids no_namespace
In the application's primary .cpp source file:
// Instantiate the StdSessionLogin component
IStdSessionLoginPtr spIStdSessionLogin;
HRESULT hResult = spIStdSessionLogin.CreateInstance(__uuidof(StdSessionLogin));
if (FAILED(hResult)) { std::cout << "Could not create the StdSessionLogin component." << std::endl; _ASSERTE(0); } try {
// Initialize the StdSessionLogin component to create // a separate, non-unified login for the client application // by specifying the session / client application name. std::cout << "Initializing the StdSessionLogin component to use NON-unified login..." << std::endl; _bstr_t sessionName(_T("WordPerfect")); spIStdSessionLogin->InitializeViaSessionName(sessionName);
// Instantiate the AppIntSession component
IAppIntSessionPtr spIAppIntSession;
hResult = spIAppIntSession.CreateInstance(__uuidof(AppIntSession)); if (FAILED(hResult)) { std::cout << "Could not create the AppIntSession component." << std::endl; _ASSERTE(0); } // Initialize the AppIntSession component with the StdSessionLogin component
std::cout << "Initializing the AppIntSession component..." << std::endl;
spIAppIntSession->Initialize(spIStdSessionLogin); // * The Client Application may invoke a SessionLogin here; otherwise, // * it will automatically be invoked as needed when commands are executed. std::cout << "Checking Login Status..." << std::endl; VARIANT_BOOL bIsLoggedIn = spIAppIntSession->IsLoggedIn(); if (bIsLoggedIn == VARIANT_TRUE) { std::cout << "User is currently Logged In." << std::endl; } else {
std::cout << "User is NOT currently Logged In." << std::endl;
std::cout << "Attempting Login..." << std::endl;
hResult = spIAppIntSession->Login(); if (FAILED(hResult)) { std::cout << "Login failed." << std::endl; _ASSERTE(0); }
std::cout << "Login succeeded." << std::endl; } // Instantiate the custom Download command component IDownloadCmdPtr spIDownloadCmd;
hResult = spIDownloadCmd.CreateInstance(__uuidof(DownloadCmd));
if (FAILED(hResult)) {
std::cout << "Could not create the Download command component.\n"; _ASSERTE(0);
} // Instantiate the ObjectStoreItem component IObjectStoreItemPtr pIObjectStoreItem; hResult = spIObjectStoreItem.CreateInstance(__uuidof(ObjectStoreItem));
if (FAILED(hResult)) {
std::cout << "Could not create the ObjectStoreItem component.\n"; _ASSERTE(0);
} // Initialize the ObjectStoreItem component with // the items' type, object store name, version series ID and item ID ItemType eItemType = eItemTypeDocument; _bstr_t bstrObjectStoreName = (_T("Alaska")); _bstr_t bstrVersionSeriesID = (_T("{6BC064A2-2D58-4B0A-AEF2-B2F8A1100000}")); _bstr_t bstrVersionID = (_T("release")); std::cout << "Initializing the ObjectStoreItem component..." << std::endl;
spIObjectStoreItem->Initialize(eItemType, bstrObjectStoreName, bstrVersionSeriesID, bstrVersionID); // Initialize the custom Download command component // with the filename and path location on the local machine, // of the downloaded object store item and optionally, // the index value of the content element to download. _bstr_t bstrPathName = (_T("C:\Downloaded Documents\filename.doc")); long contentElementIndex = 0L; std::cout << "Initializing the Download command component..." << std::endl; spIDownloadCmd->Initialize(bstrPathName, spIObjectStoreItem, contentElementIndex); // Execute the Download command and capture the response component std::cout << "Executing the Download command..." << std::endl; IAppIntCmdPtr spIAppIntCmd(spIDownloadCmd);
IAppIntRspPtr spIAppIntRsp = spIAppIntCmd->Invoke(spIAppIntSession);// Determine if the command failed, before accessing response component data hResult = spIAppIntRsp->GetHResult(); if (FAILED(hResult)) { std::cout << "The Download command failed to execute." << std::endl; // Examine the error information provided in the standard response component _bstr_t bstrErrorName = spIAppIntRsp->GetErrorName(); std::cout << "ErrorName=" << ( bstrErrorName.length() ? (LPCSTR) bstrErrorName : _T( "" ) ) << std::endl; _bstr_t bstrErrorMsg = spIAppIntRsp->GetErrorMsg(); std::cout << "ErrorMsg=" << ( bstrErrorMsg.length() ? (LPCSTR) bstrErrorMsg : _T( "" ) ) << std::endl; _bstr_t bstrErrorDetails = spIAppIntRsp->GetErrorDetails(); std::cout << "ErrorDetails=" << ( bstrErrorDetails.length() ? (LPCSTR) bstrErrorDetails : _T( "" ) ) << std::endl; _ASSERTE(0); } else { std::cout << "The Download command succeeded." << std::endl; // Obtain the response name and description from the standard response component _bstr_t bstrResponseDescription = spIAppIntRsp->GetDescription(); std::cout << "ResponseDescription=" << ( bstrResponseDescription.length() ? (LPCSTR) bstrResponseDescription : _T( "" ) ) << std::endl; _bstr_t bstrResponseName = spIAppIntRsp->GetName(); std::cout << "ResponseName=" << ( bstrResponseName.length() ? (LPCSTR) bstrResponseName : _T( "" ) ) << std::endl; // Obtain the specific response information contained in the custom DownloadRsp component IDownloadRspPtr spIDownloadRsp(spIAppIntRsp);
_ASSERTE(spIDownloadRsp != 0);
std::cout << "PathName=" << (LPCSTR) spIDownloadRsp->GetFilePathName() << std::endl;
std::cout << "MimeType=" << (LPCSTR) spIDownloadRsp->GetMimeType() << std::endl;
std::cout << "FileSize=" << spIDownloadRsp->GetContentSize() << " bytes" << std::endl; }} catch(...) { }