You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Greg Akins <an...@gmail.com> on 2009/12/16 18:58:11 UTC

Posting a file to Sling

I'm not having success POSTing a file to Sling using curl

curl =F "file=@test.txt" -F"sling:resourceType=foo/bar" -F"title=some
title" http://localhost:8080/content/mynode3

The resulting GET returns doesn't include any mention of the "file"
field.  Can anyone give me any advice?

Resource dumped by HtmlRendererServlet

Resource path: /content/mynode3

Resource metadata: {sling.resolutionPathInfo=.html,
sling.resolutionPath=/content/mynode3}
Resource properties
title: some title
sling:resourceType: foo/bar
jcr:primaryType: nt:unstructured

-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net

Re: Posting a file to Sling

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Dec 16, 2009 at 22:07, Greg Akins <an...@gmail.com> wrote:
> That was it.  Is that because the attribute on the post was file?  In
> other words, if I had used -F"widget=@test.txt" would the file be at
> mynode4/widget?

Yes, see http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html#ManipulatingContent-TheSlingPostServlet%28servlets.post%29-FileUploads

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: Posting a file to Sling

Posted by Greg Akins <an...@gmail.com>.
On Wed, Dec 16, 2009 at 4:02 PM, Alexander Klimetschek <ak...@day.com> wrote:
>
> The file should be available at
> http://localhost:8080/org.apache.sling.launchpad.webapp-5-incubator/mynode4/file
>

That was it.  Is that because the attribute on the post was file?  In
other words, if I had used -F"widget=@test.txt" would the file be at
mynode4/widget?

Thanks for your help Alexander


-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net

Re: Posting a file to Sling

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Dec 16, 2009 at 19:18, Greg Akins <an...@gmail.com> wrote:
> That command returns html which includes "Content created /content/mynode4"
>
> Browsing to http://localhost:8080/org.apache.sling.launchpad.webapp-5-incubator/mynode4.html

The file should be available at
http://localhost:8080/org.apache.sling.launchpad.webapp-5-incubator/mynode4/file

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: Posting a file to Sling

Posted by Greg Akins <an...@gmail.com>.
On Wed, Dec 16, 2009 at 1:05 PM, Alexander Klimetschek <ak...@day.com> wrote:
> It should work, ending up with a subnode file of type nt:file, but the
> curl command should start like this:

Thanks for the quick replay.  Here is what I tried this time:

$ curl -F"file=@test.txt" -F"sling:resourceType=foo/bar" -F"title=some
title" http://admin:admin@localhost:8080/org.apache.sling.launchpad.webapp-5-incubator/content/mynode4

That command returns html which includes "Content created /content/mynode4"

Browsing to http://localhost:8080/org.apache.sling.launchpad.webapp-5-incubator/mynode4.html

Results in the following output:

Resource dumped by HtmlRendererServlet

Resource path: /content/mynode4

Resource metadata: {sling.resolutionPathInfo=.html,
sling.resolutionPath=/content/mynode4}
Resource properties
title: some title
sling:resourceType: foo/bar
jcr:primaryType: nt:unstructured

Re: Posting a file to Sling

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, Dec 16, 2009 at 18:58, Greg Akins <an...@gmail.com> wrote:
> curl =F "file=@test.txt" -F"sling:resourceType=foo/bar" -F"title=some
> title" http://localhost:8080/content/mynode3

It should work, ending up with a subnode file of type nt:file, but the
curl command should start like this:

curl -F"file=@test.txt" ...

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com