incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keith Gable <zi...@ignition-project.com>
Subject Re: Image upload from App
Date Mon, 05 Dec 2011 22:28:23 GMT
Setting the Content-Type overrides Ti's handling of multipart forms.
Probably, Ti is still sending the data as if it were multipart, but with a
image/jpeg Content-Type. So the multipart document is uploaded even though
you're telling the server it's an image.

You probably need to not send Content-Type, and then you need to determine
what form element (media in { media: image }) that CouchDB expects to be
sent. If it's nested (a la Rails), do something like:

xhr.send({ "myobject[photo]": image });

Good luck with this... If you can avoid Titanium, I would recommend that
you do. I've spent countless nights doing basic things that should just
work (and do natively and in web browsers). At this point, I think I could
have written the app I'm working on in ARM assembler and spent less time
debugging. :(

---
Keith Gable
A+ Certified Professional
Network+ Certified Professional
Web Developer



On Mon, Dec 5, 2011 at 11:01 AM, <venugopal.raju@fit.fraunhofer.de> wrote:

> I can see the photo(JPEG) being attached to the CouchDB server when I run
> the application (Can see the size (KB) details, but the image does not
> open, not readable). Anyone had similar problems? Here is the Android code
> snippet written in Titanium Studio.
>
> var image = event.media;
> var xhr = Titanium.Network.createHTTPClient();
> xhr.open('PUT','
> http://129.26.160.66:5984/mc/id100/attachment.jpg?rev=42-2fd65cfa04540fb9e73ee85a42111d2e'
> );
> xhr.setRequestHeader("Content-Type", "image/jpeg");
> xhr.send({media:image});
>
>
> Regards,
>
> > We do.
> >
> > On 24 November 2011 15:07, Keith Gable <ziggy@ignition-project.com>
> wrote:
> >> Also, Titanium sucks and you can only GET and POST. Rails supports
> >> X-HTTP-Method-Override, which permits you to specify the HTTP method
> >> when
> >> posting, but I don't know about CouchDB. If CouchDB doesn't, you can't
> >> use
> >> Titanium's HTTPClient to do this.
> >> On Nov 24, 2011 8:33 AM, <venugopal.raju@fit.fraunhofer.de> wrote:
> >>
> >>> Dear members,
> >>>
> >>> I am writing an Android application in javascript (Titanium Studio),
> >>> this
> >>> application uses HTTP to PUT data to the CouchDB server. I am trying to
> >>> implement a functionality where image captured from the mobile camera
> >>> can
> >>> be uploaded to the CouchDB server via the application. How could this
> >>> be
> >>> done ? Has anyone tried such a functionality?
> >>>
> >>> Thanks & Best Regards,
> >>> Venu.
> >>>
> >>>
> >>
> >
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message