Well in order to add a photo to picasa manually, you have to send a POST
request as outlined here:

http://code.google.com/apis/picasaweb/gdata.html#Add_Photo

The way you'd do this with the Python client librrary for example is call a
method named POST which creates the headers and multipart message and then
pumps in a binary stream for the image data where the beef of the code is:

      insert_connection = atom.service.AtomService._CreateConnection(self,
          uri, 'POST', extra_headers, url_params, escape_params)

      insert_connection.send(multipart[0])
      insert_connection.send(data_str)
      insert_connection.send(multipart[1])

      while 1:
        binarydata = media_source.file_handle.read(100000)
        if (binarydata == ""): break
        insert_connection.send(binarydata)

      insert_connection.send(multipart[2])

As far as I can tell, there isn't a low level enough way of accomplishing
this with the current Javascript library.

I've tried to get around this using my own XMLHttpRequest, but I haven't
quite worked out my bug yet, because the 2 main problems you have to deal
with are:

1) cross-domain calling XMLHttpRequest
2) manually dealing with authentication

I am getting around the cross-domain issue with an Apache RewriteRule which
is working for an unauthenticated GET request.  As far as I can tell I've
constructed my request correctly according to the link outlined above and
set the following headers in Javascript:

        xmlhttp.setRequestHeader("Authorization", 'AuthSub
token="'+picasaToken+'"');
        xmlhttp.setRequestHeader("Content-type", 'multipart/related;
boundary="END_OF_PART"');
        xmlhttp.setRequestHeader("Content-length", data.length);
        xmlhttp.setRequestHeader("MIME-version", "1.0");
        xmlhttp.setRequestHeader("Connection", "close");
        xmlhttp.open("POST","post",true);
        xmlhttp.send(data);

Where "post" is the Apache rewrite:

RewriteRule ^post$
http://picasaweb.google.com/data/feed/api/user/default/album/MyTestAlbum [P]

Of course this entire process could be circumvented if the Javascript
library had a post method so there could be a little lower level control.

The end result is I have a binary stream I'm encoding on the fly and I need
to post that binary image data somehow, which insertEntry cannot accomodate.
  I accomplished this with the Python Client Library since I had access to
the source.  I think i actually may be forgetting to append the gsessionid
to my url, but it's just not very user friendly at the moment and also
requires having admin rights on Apache to add the proxy module and make the
rewrite.

It would just be nice to have a simpler way of uploading an image to picasa
given a binary stream.

-Stefan

On 10/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> On Oct 5, 10:28 am, wsstefan <[EMAIL PROTECTED]> wrote:
> > With the new Javascript Calendar library it's possible to interact
> > with Picasa Web Albums because for the most part all it needs is the
> > base service.
>
> Correct.
>
> > The one problem I'm running into is that the base service has no POST
> > method exposed like most of the other client libraries, making it
> > impossible to add in image with this library thus far?
>
> There is getEntry, insertEntry, updateEntry and deleteEntry on
> Service.  Which one is missing?
>
> > Or am I missing something?
> >
> > If not, when can POST ???
>
> Jun
>
>
> >
>


-- 
Draw online with other people at:

http://www.DrawAndShare.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to