Sean,
On 08 May 2012, at 22:17, Sean P. DeNigris wrote:
> I'm want to post an xml file with Zinc:
>
> Something like this
> curl -X POST
> "
http://user:password@.../createItem?name=newjobname"
> --data-binary "@/path/to/newconfig.xml" -H "Content-Type: text/xml"
>
> I see the form post methods, but how do I post a file?
>
> Thanks,
> Sean
I am at the moment hard at work and forcing myself to stay focused on writing the Zn documentation that I keep promising but never seem to produce ;-)
Basically, it would go like this (untested):
ZnClient new
url: '
http://hudson.server.org/createItem'; queryAt: 'name' put: 'newjobname';
username: 'user' password: 'password';
entity: (ZnEntity
with: ('/tmp/foo.xml' asReference readStreamDo: [ :stream | stream contents ]) asString
type: ZnMimeType applicationXml);
post.
You basically need to load the whole file since you have to know the length.
The #asString conversion is probably not needed (but encodings could have to be involved).
It can be done using streaming for files, as in ZnStaticFileServerDelegate>>#responseForFile: but it requires even more code.
And yes, maybe yet another convenience method like the #downloadTo: would be useful ;-)
Even guessing the mime-type from the extension is possible (as in ZnStaticFileServerDelegate>>#responseForFile:).
I'll see what I can do later.
Sven
--
Sven Van Caekenberghe
http://stfx.euSmalltalk is the Red Pill