The Initialize method is called to initialize the Upload command, by specifying the object store item to upload from a file on the local machine. The client application indicates which item to upload by specifying a version series ID or a special version name (release or current) in bstrVersionID parameter of the IObjectStoreItem interface. The client may also identify which content element to upload, by supplying the index value of the element.
NOTE If you would prefer to prompt the user for the location of the file on their local machine from which to upload the object store item, the client application must invoke the FileSaveAsDlg command before issuing the Upload command.
void spIUploadCmd->InitializeObjectStoreItem(_bstr_t bstrPathName, IObjectStoreItemPtr pIObjectStoreItem, long contentElementIndex);
...
// 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);
...