cancel
Showing results for 
Search instead for 
Did you mean: 

Throws error when uploading file to Alfresco with Curl

rumana
Champ in-the-making
Champ in-the-making
I have a php script that uploads files to Alfresco using curl, it works fine with local setup of Alfresco on my system. But, fails when the same is used to upload to production copy.

Below is the sample code:

$url ='http://admin:passwd@WEBURL:8000/alfresco/service/api/upload';
$filename = 'john.jpeg'; $mimetype= mime_content_type($filename);
$postfields = array(
  'filedata' => '@' . $filename,
  'filename' => $filename,
  'siteid' => 'mysite',
  'containerid' =>'documentLibrary',
  'uploaddirectory' =>'test',
  'contenttype' => $mimetype );



Below, is the curl response upon failure while uploading file,

{
  "status" :
{
  "code" : 500,
  "name" : "Internal Error",
  "description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},

"message" : "00031437 Unexpected error occurred during upload of new content.",
"exception" : "org.springframework.extensions.webscripts.WebScriptException - 00031437 Unexpected error occurred during upload of new content.",

"callstack" :
[
   ""      ,"java.lang.IllegalArgumentException: Class {}application\/pdf has not been defined in the data dictionary"
  ,"org.alfresco.repo.policy.ClassPolicyDelegate.get(ClassPolicyDelegate.java:98)"
  ,"org.alfresco.repo.policy.ClassPolicyDelegate.get(ClassPolicyDelegate.java:83)"
  ,"org.alfresco.repo.node.AbstractNodeServiceImpl.invokeBeforeCreateNode(AbstractNodeServiceImpl.java:283)"
  ,"org.alfresco.repo.node.db.DbNodeServiceImpl.createNode(DbNodeServiceImpl.java:363)"
  ,"sun.reflect.GeneratedMethodAccessor1147.invoke(Unknown Source)"
  ,"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
  ,"java.lang.reflect.Method.invoke(Method.java:606)"
  ,"org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)"
  ,"org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)"
  ,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)"
  ,"org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:104)"
  ,"org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)"
  ,"org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)"
  ,"com.sun.proxy.$Proxy9.createNode(Unknown Source)"
  ,"sun.reflect.GeneratedMethodAccessor1147.invoke(Unknown Source)"
  ,"sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"
  ,"java.lang.reflect.Method.invoke(Method.java:606)"
  .
  .
  .
}
1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator
Hello,

your content type parameter is incorrect. This is not meant to be the mime type of the file you are uploading, but the Alfresco specific document type, i.e. wether the file represents an invoice or such. In standard Alfresco, you usually set this value to "cm:content" for a standard type of document.

Regards
Axel