You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Simon Gaeremynck <ga...@gmail.com> on 2010/02/23 16:43:11 UTC
Uploading files and setting properties at the same time.
I'm trying to upload a file and set properties on them at the same time.
To be able to set a property on a nt:file it has to have a special mixin.
I circumvented this, by creating a new nodetype called "sakai:file" which extends the nt:file nodetype and
automatically has the appropriate mixin on it.
I can now do something like:
curl -F"./*=@README.txt" -F"./*@TypeHint=sakai:file" http://admin:admin@localhost:8080/foo/bar
curl -F"stringProp=alfa" http://admin:admin@localhost:8080/foo/bar/README.txt
This sets a property on the created file and is what I want.
But ideally, I want to combine those two into one request.
Something along the lines of
curl -F"./*=@README.txt" -F"./*@TypeHint=sakai:file" -F"./*/stringProp=alfa" http://admin:admin@localhost:8080/foo/bar
I had a quick look at the ModifyOperation and the SlingFileUploadHandler but didn't see anything in there that could handle this?
Is there another way of doing this or am I looking at this in the wrong way?
Kind regards,
Simon
Re: Uploading files and setting properties at the same time.
Posted by Alexander Klimetschek <ak...@day.com>.
On Tue, Feb 23, 2010 at 16:43, Simon Gaeremynck <ga...@gmail.com> wrote:
> I'm trying to upload a file and set properties on them at the same time.
> ...
> I can now do something like:
> curl -F"./*=@README.txt" -F"./*@TypeHint=sakai:file" http://admin:admin@localhost:8080/foo/bar
> curl -F"stringProp=alfa" http://admin:admin@localhost:8080/foo/bar/README.txt
Try specifying the * (for auto-node name generation) as part of the
POST URL. Using :nameHint you can control the node name generation
further [1]. Using the file name of the uploaded file is not supported
this way AFAIK, but it's generally not such a good idea anyway.
curl -u admin:admin -F.=@README.txt -F.@TypeHint=sakai:file
-F./stringProp=alpha http://localhost:8080/foo/bar/*
[1] http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html#ManipulatingContent-TheSlingPostServlet%28servlets.post%29-AlgorithmforNodeNameCreation
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com