AnsweredAssumed Answered

Error while uploading files to Alfresco via CURL & PHP

Question asked by biju16mvk on Jan 10, 2014
My Alfresco is throwing error like this

{ "status" : { "code" : 500, "name" : "Internal Error", "description" : "An error inside the HTTP server which prevented it from fulfilling the request." }, "message" : "00100006 Unexpected error occurred during upload of new content.", "exception" : "org.springframework.extensions.webscripts.WebScriptException - 00100006 Unexpected error occurred during upload of new content.", "callstack" : [ "" ,"org.mozilla.javascript.JavaScriptException: [object Error] (file:\/C:\/Alfresco\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/upload\/upload.post.js#405)" ,"org.mozilla.javascript.gen.c6._c3(file:\/C:\/Alfresco\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/upload\/upload.post.js:405)" ,"org.mozilla.javascript.gen.c6.call(file:\/C:\/Alfresco\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/upload\/upload.post.js)" ,"org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)" ,"org.mozilla.javascript.gen.c6._c0(file:\/C:\/Alfresco\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/upload\/upload.post.js:409)" ,"org.mozilla.javascript.gen.c6.call(file:\/C:\/Alfresco\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/upload\/upload.post.js)" ,"org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)" ,"org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)" ,"org.mozilla.javascript.gen.c6.call(file:\/C:\/Alfresco\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/upload\/upload.post.js)" ,"org.mozilla.javascript.gen.c6.exec(file:\/C:\/Alfresco\/tomcat\/webapps\/alfresco\/WEB-INF\/classes\/alfresco\/templates\/webscripts\/org\/alfresco\/repository\/upload\/upload.post.js)" ,"org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:502)" ,"org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:200)" ,"org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)" ,"org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:174)" ,"org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)" ,"org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1305)" ,"org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)" ,"org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:429)" ,"org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:452)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:491)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:529)" ,"org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:341)" ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)" ,"org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)" ,"org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)" ,"javax.servlet.http.HttpServlet.service(HttpServlet.java:728)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)" ,"org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:439)" ,"org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:178)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)" ,"org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)" ,"org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)" ,"org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)" ,"org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)" ,"org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)" ,"org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)" ,"org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)" ,"org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)" ,"org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)" ,"org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)" ,"org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)" ,"org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)" ,"org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)" ,"org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)" ,"java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)" ,"java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)" ,"java.lang.Thread.run(Thread.java:724)" ,"org.springframework.extensions.webscripts.WebScriptException: 00100006 Unexpected error occurred during upload of new content." ,"org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1053)" ], "server" : "Community v4.2.0 (r56674-b4848) schema 6,033", "time" : "Jan 10, 2014 10:57:11 AM" }

Following is the code I used to upload files to Alfresco

<?php

$filePath='fluentxs_view.txt';

$data = array(
"filedata" => $filePath,
"siteid" => 'test-site',
"containerid" => 'documentLibrary'
);
$data = json_encode($data);
//since I am using localhost I avoided these parameters
//$postFields['tags'] = “”;
//$postFields['licenseinfo'] = “”;
//$postFields['token'] = “”;
$api_url = 'http://localhost:8080/alfresco/service/api/upload?alf_ticket=TICKET_70f0f6c0f95c764441f638ebd9ff1152300abddf';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $api_url);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_POST, true);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $data);

//execute the API Call
$returned_data = curl_exec($curl_handle);
$resultStatus = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
print_r($returned_data);

?>

Whats wrong with this. Please help me out.

Outcomes