You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ace.apache.org by Daan Veldhof <da...@gmail.com> on 2015/10/15 13:43:57 UTC
Uploading artifact through REST
Hi everyone,
I'm trying to setup ACE so I don't have to interact with the Web UI, but I
can't find a clear REST call for uploading an artifact. I know there is the
way with the URL to the local file, but I want to be able to upload the
artifacts from another PC, so that's not really an option. I also know
there is this call below, but I don't know exactly how to add the file to
the request
- - POST /*obr*/${ID}, submits a resource to the *OBR*. The ${ID} is used
as the resource name and the content as its value. Returns a 409 if there
is a conflict with another resource;
I tried adding the file to the request with python using httplib
--------------------------------------------------------------------------
conn.request("POST", "/obr/bla.jar", open("bla.jar", "r"))
response = conn.getresponse()
print response.status, response.reason
data = response.read()
print data
--------------------------------------------------------------------------
And I tried it with python using urllib2 and poster
--------------------------------------------------------------------------
register_openers()
datagen, headers = multipart_encode({"blah": open("bla.jar", "rb")})
request = urllib2.Request("http://localhost:8080/obr/bla.jar", datagen,
headers)
print urllib2.urlopen(request).read()
--------------------------------------------------------------------------
The GET and DELETE on /obr/${ID} do work for me.
Regards
Re: Uploading artifact through REST
Posted by Jan Willem Janssen <ja...@luminis.eu>.
Hi Daan,
> On 15 Oct 2015, at 13:43, Daan Veldhof <da...@gmail.com> wrote:
>
> I'm trying to setup ACE so I don't have to interact with the Web UI, but I
> can't find a clear REST call for uploading an artifact. I know there is the
> way with the URL to the local file, but I want to be able to upload the
> artifacts from another PC, so that's not really an option. I also know
> there is this call below, but I don't know exactly how to add the file to
> the request
>
> - - POST /*obr*/${ID}, submits a resource to the *OBR*. The ${ID} is used
> as the resource name and the content as its value. Returns a 409 if there
> is a conflict with another resource;
>
> I tried adding the file to the request with python using httplib
> --------------------------------------------------------------------------
> conn.request("POST", "/obr/bla.jar", open("bla.jar", "r"))
> response = conn.getresponse()
> print response.status, response.reason
> data = response.read()
> print data
> —————————————————————————————————————
IIRC: you should issue a POST request to /obr?filename=bla.jar with a
proper ContentType header. The ContentType header is used to determine
what kind of data you’re posting to the OBR. For bundles this value
should be "application/vnd.osgi.bundle".
Mind that bundles with the same bundle symbolic name and bundle version
can only uploaded once! Each bundle needs to have a unique version in
order to make it upload successfully to the OBR.
HtH,
--
Met vriendelijke groeten | Kind regards
Jan Willem Janssen | Software Architect
+31 631 765 814
My world is revolving around INAETICS and Amdatu
Luminis Technologies B.V.
Churchillplein 1
7314 BZ Apeldoorn
+31 88 586 46 00
http://www.luminis-technologies.com
http://www.luminis.eu
KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01