On 6/14/10 1:31 PM, Tony Giaccone wrote: > > So I think I'm asking too specific a question. > > What I want to do is load up a resource that when viewed through webdav will > be seen as a file with content. > > I saved a file using a text editor into the webdav system, when I browse this > url: > > http://localhost:8080/sling/content/SimpleData.xml > > I get this xml: > > <SimpleData jcr:primaryType="nt:file" > jcr:created="2010-06-14T11:58:44.686-04:00" jcr:createdBy="admin"> > <jcr:content jcr:primaryType="nt:resource" > jcr:uuid="6506b4c2-ad52-4ff2-bf16-90c17311e8ad" > jcr:data="VGVzdCBvZiBkYXRhIGluIGEgZmlsZS4g" > jcr:lastModified="2010-06-14T11:58:44.750-04:00" jcr:lastModifiedBy="admin" > jcr:mimeType="text/plain"/> > </SimpleData> > File creation is a very specific use case. You have to use the -T curl option. Otherwise, curl uses a simple form post when it needs to use multipart. See the File Uploads section of http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html. There are also examples of file posting with curl on http://sling.apache.org/site/discover-sling-in-15-minutes.html
> When I loaded a node using this curl > > curl -F"sling:resourceType=foo/bar" -F"title=some title" > http://admin:ad...@localhost:8080/sling/content/mynode > > It looks like this: > <mynode jcr:primaryType="nt:unstructured" sling:resourceType="foo/bar" > title="some title"/> > > > I'd like to get the XML to look like this: > > <mynode jcr:primaryType="nt:file" sling:resourceType="foo/bar" title="some > title"/> > Not sure how literally to take this, but you can't do exactly this for a few reasons. First, nt:file nodes need to have a jcr:content child node. Secondly, you would need to mix in sling:Resource to allow the sling:resourceType property. Finally, you would need a different mixin to add the title property (mix:title could be used, although that defines jcr:title, not title). > So I tried this: > > curl -F"sling:resourceType=foo/bar" -F"jcr:primaryType=Sling:file" > -F"jcr:title=node3" http://admin:ad...@localhost:8080/sling/content/node3 > > foo.html Really? When I use this command, I get a 500 error that "Sling" isn't a registered namespace prefix. Switching the jcr:primaryType field to nt:file fails for the reason give above. Creating an nt:file node with mixins and other custom properties does not appear to be possible with a single curl command. What you can do is something like this: curl -T foo.txt http://admin:ad...@localhost:8080/content/test/foo.txt curl -Fjcr:mixinTypes=sling:Resource -Fsling:resourceType=foo/bar \ -Fjcr:mixinTypes=mix:title "-Fjcr:title=some title" \ http://admin:ad...@localhost:8080/test/content/foo2.txt Note - because JCR System View doesn't support multi-valued properties, viewing the XML of the node created above will not show mixins. You have to use Doc View or JSON: curl http://localhost:8080/test/content/foo2.txt.tidy.json { "sling:resourceType": "foo/bar", "jcr:title": "some title", "jcr:createdBy": "admin", "jcr:mixinTypes": [ "mix:title", "sling:Resource" ], "jcr:created": "Mon Jun 14 2010 14:02:52 GMT-0400", "jcr:primaryType": "nt:file" } HTH, Justin > > but still got this: > > <node3 jcr:primaryType="nt:unstructured" jcr:title="node3" > sling:resourceType="foo/bar"/> > > > In each case the jcr:primaryType stayed nt:unstructured, obviously I'm > missing some important point. > > > > Tony > > On Jun 14, 2010, at 12:41 PM, Justin Edelson wrote: > >> On 6/14/10 12:37 PM, Tony Giaccone wrote: >>> >>> >>> I notice when I use curl to insert a new record, it always ends up with >>> jcr:primaryType="nt:unstructured". >>> >>> >>> Is it possible to set that value when using curl? >>> >>> >>> >>> Tony Giaccone >> -Fjcr:primaryType=[your primary type] >> >> i.e. >> curl -Fjcr:primaryType=sling:Folder >> http://admin:ad...@localhost:8888/test/content >> >> mixins are the same: >> >> curl -Fjcr:primaryType=sling:Folder -Fjcr:mixinTypes=mix:referenceable >> http://admin:ad...@localhost:8888/test/content2 >> >> Justin >
