Upload Command

The Upload command silently uploads a specific version of an object store item from a specified file on the local machine. The client application must use the IUploadCmd interface to specify the item to upload and may optionally identify which content element to upload using the index value. When the object store item is currently checked-out, the client may use the Upload command to save changes to the reservation object.

After the Upload command has been executed by calling IAppIntCmd::Invoke, an Upload response component is returned. Client applications may interact with the response component via the standard IAppIntRsp and custom IUploadRsp interfaces. For more information about working with command and response components and their COM interfaces, see Command and Response components.

NOTE The Upload command does not perform any type of checkin command or invoke a graphical user interface, it simply uploads the content for a specified file.

Reference

DLL FnAppIntUploadCmd.dll
See Also Download command

Interfaces

The Upload command uses the following interfaces:

Interface Description
IUploadCmd

This is a custom interface used to initialize the data contained in the Upload command component. The client application can use this interface to specify the object store item and content element to upload, as well as save changes to the reservation object for an item.

IUploadRsp

This is a custom interface for the Upload response component that is returned when the Upload command is executed. This interface enables the client application to obtain the MIME type and size (number of bytes) of the object store item that was uploaded.

IAppIntCmd

This is a standard interface which is automatically used by the Upload command to invoke the Upload command component. The client application executes the Upload command by calling this interface and passing the AppIntSession component on which the Upload command component is invoked. Each time the command is executed, an Upload response component is returned.

IAppIntRsp

This is a standard interface that is automatically used by the Upload command to determine the success or failure of the command, as well as retrieve any error code or messages.

Example

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\FnAppIntUploadCmd.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 Upload command component IUploadCmdPtr spIUploadCmd;
hResult = spIUploadCmd.CreateInstance(__uuidof(UploadCmd));
if (FAILED(hResult)) {
std::cout << "Could not create the Upload command component.\n"; _ASSERTE(0);
} // Instantiate the ObjectStoreItem component IObjectStoreItemPtr spIObjectStoreItem; 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, name, version series ID and version ID. ItemType eItemType = eItemTypeDocument; _bstr_t bstrObjectStoreName = (_T("Alaska")); _bstr_t bstrVersionSeriesID = (_T("{6BC064A2-2D58-4B0A-AEF2-B2F8A1100000}")); _bstr_t bstrVersionID = (_T("{DDE54469-36D9-4fe9-8676-445E4994DE1F}")); std::cout << "Initializing the ObjectStoreItem component..." << std::endl;
spIObjectStoreItem->Initialize(eItemType, bstrObjectStoreName, bstrVersionSeriesID, bstrVersionID); // Initialize the custom Upload command component with // the filename and path location on the local machine, // of the object store item to upload and optionally, // the index value of the content element to upload. _bstr_t bstrPathName = (_T("C:\Uploaded Documents\filename.doc")); long contentElementIndex = 0L; std::cout << "Initializing the Upload command component..." << std::endl; spIUploadCmd->InitializeObjectStoreItem(bstrPathName, spIObjectStoreItem, contentElementIndex); // Execute the Upload command and capture the response component std::cout << "Executing the Upload command..." << std::endl; IAppIntCmdPtr spIAppIntCmd(spIUploadCmd);
IAppIntRspPtr spIAppIntRsp = spIAppIntCmd->Invoke(spIAppIntSession);
// Determine if the command failed, before accessing response component data hResult = spIAppIntRsp->GetHResult(); if (FAILED(hResult)) { std::cout << "The Upload 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 Upload 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 UploadRsp component IUploadRspPtr spIUploadRsp(spIAppIntRsp);
_ASSERTE(spIUploadRsp != 0); std::cout << "PathName=" << (LPCSTR) spIUploadRsp->GetFilePathName() << std::endl;
std::cout << "MimeType=" << (LPCSTR) spIUploadRsp->GetMimeType() << std::endl;
std::cout << "ContentSize=" << spIUploadRsp->GetContentSize() << " bytes" << std::endl; }
} catch(...) { }