Jonathan--

That didn't work. I think it's because the Content-Type comes across
as a unique string each time a request as made. For example:

  multipart/form-data; boundary=----------------------------6068cb2e3a84
  multipart/form-data; boundary=----------------------------eb944e1f8467

So, I did something similar to the following (in Scala):

  val app = new WebApp()
  val multi = MediaType.register("multipart/*", "file upload")
  app.getMetadataService().addExtension("multipart", multi, true)

in hopes that the wildcard would pick things up. But, alas, it didn't.
The only thing that works for me is to override the post method and
then do something like:

  if (entity.getMediaType().toString().contains("multipart")) {
    // do parsing here
  }

All of which means that I'm not stuck. Is there some way to
characterize the media type such that it'll pick up the content-types
(above) as sent by clients?

Keith

On Tue, Sep 28, 2010 at 1:29 AM, Jonathan Hall <[email protected]> wrote:
>
> Hi Keith,
>
> This is all set in org.restlet.service.MetadataService.
>
> "form" is a  MediaType.APPLICATION_WWW_FORM , which explains why the
> multipart is returning a 405.
> A "multipart" (MediaType.MULTIPART_FORM_DATA ) request doesn't seem to
> be in the MetadataService, so you could add your own.
>
>  From your Application: getMetadataService().addExtension("multipart",
> MediaType.MULTIPART_FORM_DATA, true);
>
> then you can do:
>
> @Post("multipart")
> ...
>
> Hope this helps,
>
> Jon
>
> On 28/09/10 02:30, Keith Irwin wrote:
> >
> >
> > On Mon, Sep 27, 2010 at 5:03 PM, Keith Irwin <[email protected]
> > <mailto:[email protected]>> wrote:
> >
> >     Folks--
> >
> >     Using restlets 2.1 snapshot
> >
> >     I have a method defined like this:
> >
> >       @Post("form")
> >       public Representation accept(Representation r) {
> >          ...
> >       }
> >
> >     When I use the following command line to test:
> >
> >        curl -v -d foo=bar http://localhost:9000/my/route
> >
> >     everything works just fine. I'm getting a representation of type
> >     application/x-www-form-urlencoded, which is what I'd expect.
> >
> >     However, if I do the following:
> >
> >       curl -v -F foo=bar http://localhost:9000/my/route
> >
> >     which sends the data as multipart/form-data, I get a 405, Method
> >     Not Allowed response.
> >
> >
> > When I override the post method in my ServerResource subclass and
> > print out the media type of the entity, I get the following:
> >
> > multipart/form-data; boundary=----------------------------e5eac570d03e
> >
> > rather than just plain old: "multipart/form-data", which is what I'd
> > expect based on the value of the MediaType.MULTIPART_FORM_DATA object.
> >
> > Not sure if this might be the problem.
> >
> > Keith
> >
> >
> >     If I do NOT use the @Post("form"), no matter what I do I get the 405.
> >
> >     I've got the fileupload extensions installed. Is there something
> >     I'm missing? What token should I include in the @Post annotation?
> >      "multipartform" doesn't seem to work.
> >
> >     Should I downgrade to 2.0?
> >
> >     Keith
> >
> >
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2665654

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2665809

Reply via email to