multipart post fails

20 views
Skip to first unread message

marik

unread,
Nov 16, 2010, 2:42:57 AM11/16/10
to rhomobile
I'm trying to test multipart post with:

Rho::AsyncHttp.upload_file(
:url => 'http://my_uri_here/',
:multipart => [
{
:filename =>
File.join(Rho::RhoApplication::get_base_app_path(), 'rhoconfig.txt'),
:name => "model[file]",
},
{
:body => "upload test",
:name => "model[text]", # optional, 'blob' used as default
#:content_type => "plain/text" # optional, 'application/x-
www-form-urlencoded' used as default
}])

and on backend server(running rails 3) I get error:

NoMethodError (undefined method `rewind' for "upload test":String)

It's failing to process multipart request from mobile app.

Any suggestions?!

Thanks!



marik

unread,
Nov 16, 2010, 11:13:31 PM11/16/10
to rhomobile
Ok I did some debugging and found(I'm pretty sure) problem. Here's
result https://gist.github.com/702962

I didn't read http RFC though. Patch for AsyncHttp is there aswell.

As workaround you may want to append parameters to uri instead
applying patch.

evgeny vovchenko

unread,
Nov 17, 2010, 5:21:54 AM11/17/10
to rhom...@googlegroups.com
I just remove default Content-Type, this is application responsibility to
set Content-Type:

pItem->m_strContentType = oItem.getString("content_type", "");

Wiki also updated.

Thank you for catching this!

Regards,
Evgeny.

--
You received this message because you are subscribed to the Google Groups
"rhomobile" group.
To post to this group, send email to rhom...@googlegroups.com.
To unsubscribe from this group, send email to
rhomobile+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rhomobile?hl=en.

marik

unread,
Nov 17, 2010, 8:37:29 PM11/17/10
to rhomobile
That works too. Thanks!

On Nov 17, 4:21 am, "evgeny vovchenko" <evgenyvovche...@gmail.com>
wrote:
> I just remove default Content-Type, this is application responsibility to
> set Content-Type:
>
> pItem->m_strContentType = oItem.getString("content_type", "");
>
> Wiki also updated.
>
> Thank you for catching this!
>
> Regards,
>  Evgeny.
>
> -----Original Message-----
> From: rhom...@googlegroups.com [mailto:rhom...@googlegroups.com] On
> Behalf Of marik
> Sent: Wednesday, November 17, 2010 7:14 AM
> To: rhomobile
> Subject: [rhomobile] Re: multipart post fails
>
> Ok I did some debugging and found(I'm pretty sure) problem. Here's resulthttps://gist.github.com/702962
Reply all
Reply to author
Forward
0 new messages