02-10-2009 01:19 PM
<cfhttp url="#APPLICATION.alfrescoRoot#/service/api/login?u=#APPLICATION.alfrescoUsername#&pw=#APPLICATION.alfrescoPassword#" method="GET"/>
<cfset myTicket = XMLParse(CFHTTP.FileContent).ticket.XmlText>
<cfhttp url="http://localhost:8080/alfresco/upload/test.pdf?ticket=#myTicket#" method="put">
<cfhttpparam type="file" name="myFile" file="C:\test.pdf">
</cfhttp>
<cfdump var="#CFHTTP#">
02-13-2009 04:22 PM
<webscript>
<shortname>createNode</shortname>
<description>Create a node to stream file upload from UploadContentServlet into</description>
<url>/createNode?fileName={fileNameArgument}</url>
<format default="xml">argument</format>
<authentication>user</authentication>
</webscript>
var name = args.fileName;
var resultString = "Action failed";
var resultCode = false;
try {
resultString = "Could not create node";
var nodeNew;
var nodeRef;
if((name == null) || (name == ""))
{
resultString = "node must be given a name";
}
else
{
nodeParent = roothome.childByNamePath("Company Home/Upload");
var nodeNew = nodeParent.createNode(name, "cm:content");
}
if(nodeNew != null)
{
resultString = "nodeRef created";
resultCode = true;
nodeRef = nodeNew.nodeRef;
}
}
catch (e)
{
resultString = "Action failed due to exception";
}
model.resultString = resultString;
model.resultCode = resultCode;
model.nodeRef = nodeRef;
<?xml version="1.0" encoding="ISO-8859-1"?>
<result>
<resultString>${resultString}</resultString>
<resultCode>${resultCode?string}</resultCode>
<nodeRef>${nodeRef?string}</nodeRef>
</result>
<!— Get a connection ticket —>
<cfset httpURL = "http://" & alfrescoRoot & "/service/api/login?u=" & alfrescoUsername & "&pw=" & alfrescoPassword>
<cfhttp url="#httpURL#" method="GET" />
<cfset ticket = XMLParse(Trim(CFHTTP.FileContent)).ticket.XmlText>
<!— Create a node in the repository with the createNode webscript —>
<cfset httpURL = "http://" & alfrescoRoot & "/service/createNode?fileName=test.pdf&alf_ticket=" & ticket>
<cfhttp url="#httpURL#" method="GET" />
<cfset nodeRef = XMLParse(CFHTTP.FileContent).result.nodeRef.xmlText>
<cfset nodeRef = Right(nodeRef, Len(nodeRef) - (Find("workspace://SpacesStore/", nodeRef) + 23))>
<!— Send the file to the UploadContentServlet with an HTTP PUT —>
<cfset httpURL = "http://" & alfrescoRoot & "/upload/workspace/SpacesStore/" & nodeRef & "/test.pdf?ticket=" & ticket">
<cfhttp url="#httpURL#" method="PUT">
<cfhttpparam type="file" name="testFile" file="C:\test.pdf">
</cfhttp>
02-13-2009 06:31 PM
02-16-2009 12:37 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.