Hi!
Is there a function to download a specific file from the Content Server through Oscript?
Best Regards,
Diogo Portela
File Download Posted bydiogo.portela_ext@netpeople.pt (Portela, Diogo)On 04/16/2014 06:41 AM Hi! Is there a function to download a specific file from the Content Server through Oscript? Best Regards, Diogo Portela[To post a comment, use the normal reply function]Forum:Content Server Development ForumContent Server:Content Server
Hi,
I meant downloading the file in the Content Server to a folder in the file system. I can get the node, I need to know if and how I can just put the node in the folder in my filesystem.
Best regards and thanks for the help
Hi
When accessing various operations developers should be using the LLNode interfaces, the direct low-level DAPI calls when possible. For the different object types this is where the business logic resides, including triggers for audit. If it is found there is no interface for accessing the object etc, then that is an issue to be recorded as a bug.
Regards
David
In LLNode…
function Assoc NodeFetchVersion(\
DAPINODE node,\
DAPIVERSION version = UNDEFINED,\
Dynamic fetchInfo = UNDEFINED,\
Dynamic context = UNDEFINED )
One of the following settings for the destination in order of the checking
fetchInfo.FilePath = File path to send it to ( String )
fetchInfo.Socket = Socket handle
fetchInfo.Text = hand back the text ( < 10K ) directly
Thank you both for your answers.
I tried calling the NodeFetchVersion method.
I set the DAPINODE using the GetNodeByID function as I do in other scripts and then I defined an Assoc called fetchInfo and defined the fetchInfo.FilePath to the path I wanted
When I called the function, I got an error saying the file already exists. Do I need to set the fetchInfo.Socket and the fetchInfo.Text?
I did the following
Hi Diogo, try using the full path in the FilePath parameter:
FilePath
fetchInfo.FilePath = "C:\temp\filename.ext"
Also, you should use the $LLIAPI.LLNode for the type you're applying this to. E.g.,
$LLIAPI.LLNode
Object LLNode = $LLIAPI.LLNodeSubsystem.GetItem ( node.pSubtype )
Ok took the script you provided and expanded it a bit….. it will handle up to a 1000 file name collisions, but the real fix was you need to provide the full path and filename of the destination. Ideally if it is to go to the web $WebDoc.WebDocUtils.NodeToWeb should be used for the setting up the name for the correct browser and etag information. But lacking that….
// reference to the node itself
Integer nodeID = 2000630436
// locals
DAPINODE node
Assoc fetchInfo
Object llNode
Assoc checkVal
Integer index
String filename
String path = 'c:\temp\'
Object dapiCtx = prgCtx.DSession()
//
// off to get the object
node = DAPI.GetNodeByID( dapiCtx.fSession, nodeID)
if ( IsNotError( node ) )
// so far the object is good
filename = node.pName
if ( File.Exists( path + filename ) )
// this is limited to 1000 versions of the file :-)
for index = 1 to 1000
checkVal = $WebDoc.WebDocUtils.GetFileNameParts( node.pName )
// ensure the extension, is exists is still correct. On down the correct app will still be executed
if ( Length( checkVal.extension ) > 0 )
// there is an extension on the name, put the count before the extension
filename = Str.Format( "%1[%2].%3", checkVal.basename, index, checkVal.extension )
else
filename = Str.Format( "%1[%2]", checkVal.basename, index )
end
breakif ( !File.Exists( path + filename ) )
// Set the full path & filename to the destination file
fetchInfo.FilePath = path + filename
llNode = $LLIAPI.LLNodeSubsystem.GetItem ( $TypeDocument )
checkVal = llNode.NodeFetchVersion( node, Undefined, fetchInfo )
if ( checkVal.ok == TRUE )
// Success in the download. Carry on
echo( "Successful: ", fetchInfo.FilePath )
// Oops, something happened
echo( "Error: ", checkVal.errMsg )
echo( "Error in retrieving the object: ", nodeID )