AnsweredAssumed Answered

Uploading content to user sandbox using RestfulAPI

Question asked by bigobigo on Nov 17, 2011
Latest reply on Aug 12, 2014 by narayana.giri
Hi everyone,

I'm struggling with - as it seemed to be really trivial and basic finctionality of Alfresco - sandbox content upload via RestfulAPI.

I belive my configuration is fairly standard and during long searches I've seen a few similar to mine posts, which have not been answered. That is why I've decided to create this topic.

I have created a web project called PIM, prepared simple structure for content upload and currently trying to upload image

with RestfulApi or provided uploadServlet

to particular user's sandbox -> pim–admin where pim is the name of my web project.

Using RestfulAPI approach:
http://192.168.0.141:8080/alfresco/service/api/wcm/webprojects/pim/sandboxes/pim--admin/assets/www/avm_webapps/ROOT/MY_FOLDER?alf_ticket='+ticket and JSON data like name, content, type
works fine only for text files and parsing binary data with JSON rather difficult that is why I have switched to uploadServlet:
http://wiki.alfresco.com/wiki/URL_Addressability and I stucked.

1. How to upload anything with this servlet to user's sandbox ?
2. How to prepare correct avm path for upload servlet ?


Uploading image without specifying nodeRef works great, but where it is actually uploading a file ?

Example URL with NodeRef not provided:
/alfresco/upload/myfile.pdf

and returns reference like:
contentUrl=store://2011/11/17/7/48/bea3f54a-5d8b-4976-a1bb-9119b4726c73.bin|mimetype=image/jpeg|size=0|encoding=UTF-8|locale=en_US_

I simply cannot find it anywhere using web client's search interface of Alfresco.

When I try to specify the right path to sandbox

http://192.168.0.141:8080/alfresco/upload/workspace/SpacesStore/pim/sandboxes/pim--admin/assets/www/avm_webapps/ROOT/MY_FOLDER/C21199205_3.jpg?ticket='+ticket

I get Apache error: 417 Expectation Failed and adding request header like "Expect" - "100-continue" doesn't solve a problem.

I'm using JAVA PutMethod and InputStreamRequestEntity as a request body, so I think the approach is right - as I said it works fine without nodeRef.

Please provide any information for forming right AVM paths in this context.

How to upload images, pdfs into admin's sandbox ????

Luke.


Little update.

I have changed the nodeRef in actual servletUpload call to:

http://192.168.0.141:8080/alfresco/upload/avm/pim--admin/-1;www;avm_webapps;ROOT;MY_FOLDER/C21199205_3.jpg?ticket='+ticket

and now getting thie exception:

org.alfresco.repo.security.permissions.AccessDeniedException: 10170001 Access Denied.  The system is currently in read-only mode.
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:57)

Caused by: org.springframework.dao.TransientDataAccessResourceException: SqlMapClient operation; SQL [];  
— The error occurred in alfresco/ibatis/#resource.dialect#/avm-insert-SqlMap.xml. 
— The error occurred while applying a parameter map. 
— Check the alfresco.avm.insert_AVMNode-InlineParameterMap. 
— Check the statement (update failed). 
— Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:  
— The error occurred in alfresco/ibatis/#resource.dialect#/avm-insert-SqlMap.xml. 
— The error occurred while applying a parameter map. 
— Check the alfresco.avm.insert_AVMNode-InlineParameterMap. 
— Check the statement (update failed). 
— Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed


Alfresco Engineers, please respond.

Outcomes