AnsweredAssumed Answered

calling upload webscript using ajax and json callback

Question asked by harshit.kapoor on Sep 9, 2015
Latest reply on Dec 16, 2015 by hdalang
Hi All,

I am new to Alfresco.
My requirement is that I need to upload file (from my webclient IE9 HTML4) to Alfresco and get an id back with which it can be accessed later.
I think the above can be achieved by using Upload webscript (POST for data to http://localhost:8080/alfresco/service/api/upload).
This webscript returns Json back. I need to parse this Json and fetch noderef.

I need to do this using AJAX (jquery or XMLHTTPRequest).

I found that webscripts that return Json can use alf_callback to handle the reply.
I created very rudimentary html page to test this out.
In a post I saw that in order to get the alf_callback to work, we need to enable it using custom-web-context.xml.

I am not able to get the custom-web-context.xml configured properly

I tried the following:

     <bean id="webscripts.container" class="org.alfresco.repo.web.scripts.TenantRepositoryContainer" parent="baseAlfrescoRepositoryContainer" init-method="setup">
      <property name="name"><value>Repository</value></property>
      <property name="allowCallbacks"><value>true</value></property>

and the following:
<?xml version='1.0' encoding='UTF-8'?>


      <bean id="webscripts.container" parent="webscripts.abstractcontainer" class="org.springframework.extensions.webscripts.PresentationContainer">
      <property name="name"><value>Repository</value></property>
      <property name="allowCallbacks"><value>true</value></property>

But both did not work.
I am not able to get the custom-web-context.xml configured properly.

Could you please help?