Hi,
I am finding that if I upload a new document with a call CreateContext, followed by UploadContent, every thing is fine,
But If I try and upload a new version,
calling AddVersionContext, then UploadContent, the object ID returned by UploadContent is wrong and does not relate to any opbjects that I can find in Content Server.
Yes, I am using the CWS, No, there is no error. The version uploads and is visible from CS Web Page...
Basically, we are uploading blocks of files, tey may already exist, in which case they are added as a new version, or they are added.
Preceeding code locates the correct node to add the file too, sets metadata, categories and attributes.
This is the code
string contextID = null;
FileInfo fileInfo = new FileInfo(filename);
Node retval = null;
ReAuthenticateIfRequired();
// Call the CreateDocumentContext() method to create the context ID
try
{
// first, check if the document exists
Node existing = fDocManService.GetNodeByName(ref fDocsAuthentication, NodeID, name);
if (existing != null)
{
Console.Write("File Exists, returning ContextIdcontext ID...");
log.Debug("File Exists, returning ContextIdcontext ID...");
contextID = fDocManService.AddVersionContext(ref fDocsAuthentication, existing.ID, metadata);
UpdateAuthenticationTokens(fDocsAuthentication.AuthenticationToken);
Console.WriteLine("Success! : " + contextID);
log.Debug("Success! : " + contextID);
}
else
{
Console.Write("Generating context ID...");
log.Debug("Generating context ID...");
contextID = fDocManService.CreateDocumentContext(ref fDocsAuthentication, NodeID, name, null, false, metadata);
UpdateAuthenticationTokens(fDocsAuthentication.AuthenticationToken);
Console.WriteLine("Success! : " + contextID);
log.Debug("Success! : " + contextID);
}
}
catch (FaultException f)
{
Console.WriteLine("Faulted: " + f.Code.Name + " : " + f.Message);
log.Error("Faulted: " + f.Code.Name + " : " + f.Message);
return retval;
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.ToString());
log.Error("Error: " + e.ToString());
return retval;
}
FileStream fileStream = null;
try
{
fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.ToString());
log.Error("Error: " + e.ToString());
return retval;
}
// Create the FileAtts object to send in the upload call
FileAtts fileAtts = CreateFileAttsFromFileInfo(fileInfo);
// Call the UploadContent() method to upload the file
try
{
Console.WriteLine("Uploading file..." + fileAtts.FileName);
log.Debug("Uploading file..." + fileAtts.FileName);
string objectID = fContentService.UploadContent(ref fContentAuthentication, contextID, fileAtts, fileStream);
UpdateAuthenticationTokens(fContentAuthentication.AuthenticationToken);
Console.WriteLine("New document uploaded with ID = {0}\n", objectID);
log.Debug("New document uploaded with ID = " + objectID);
retval = fDocManService.GetNode(ref fDocsAuthentication, int.Parse(objectID));
UpdateAuthenticationTokens(fDocsAuthentication.AuthenticationToken);
}
catch (FaultException f)
{
Console.WriteLine("Faulted: " + f.Code.Name + " : " + f.Message);
log.Error("Faulted: " + f.Code.Name + " : " + f.Message);
return retval;
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.ToString());
log.Error("Error: " + e.ToString());
return retval;
}
finally
{
fileStream.Close();
}
return retval;
To all intents and purposes this was working, but I have changed the way some attributes are applied. So I have two categories, one of which has a set as well as an attribute , so I can have up to 50 "set" rows, with up to 50 Attribute values in each row...Giving me a total of 2500.
The only change I have made is adding this extra category. Again, the attribute values duly appear in CS.
I can Kludgily work around it by storing the node ID of the existing document, but I am more disturbed as to why I get an erroneous object id returned from the call to UploadContent. Does nt inspire confidence that the upload occured correctly...
Please can you help.