Search code examples
jspfile-uploadjcrsling

Apache Sling giving access denied error when uploading a file


By below command I created the node

curl -u admin:admin -F"sling:resourceType=fileu/script" -F"title=node for file upload" http://localhost:8080/fileu/mynode

by below commands I added resourceType

curl -X MKCOL -u admin:admin http://localhost:8080/apps/fileu
curl -X MKCOL -u admin:admin http://localhost:8080/apps/fileu/script

the script i.e. JSP page was added by the following command

curl -u admin:admin -T fileu.script/html.jsp http://localhost:8080/apps/fileu/script/html.jsp

the code inside the JSP page is:

    <html>
<body>
<form method="POST" action="/fileu" enctype="multipart/form-data">
    <input type="file" name="*" />
    <input type="hidden" name="*@TypeHint" value="nt:file" />
    <input type="Submit" />
</form>
</body>
</html>

I access the script by the following URL

http://localhost:8080/fileu/mynode.html

and I get error when I upload the file, in browser:

Error while processing /fileu

Status  
500
Message 
javax.jcr.AccessDeniedException: Access denied.
Location    /fileu
Parent Location /
Path    
/fileu
Referer http://localhost:8080/fileu/mynode.html
ChangeLog   
<pre></pre>

What is the issue? Please help. Thanks.


Solution

  • It seems your current user is 'anonymous'. Make sure 'anonymous' is permitted to add file or node.