Your code looks good at a glance but I dont really have time to examine it.
If you want, I wrote the same thing in PHP and it works great.  Feel free to
download my code and take a look.  You can download it here:

http://cameronhinkle.com/blog/id/6092494116456557039

The code is in Picasa.php and the method name is postImage(). According to
my documentation it's at line 1094 so that should at least be close.

Hope that helps,
Cameron

On Tue, Dec 22, 2009 at 5:25 AM, johannes sp <[email protected]> wrote:

> Hi!
>
> I am trying to upload a foto to Picasa using the Protocol API. I do
> this in Android, so I can't use the Java Client API...
>
> Can anyone have a short eye on my code? Tried to do it exactly like
> the Dev. Guide (http://code.google.com/intl/de-DE/apis/picasaweb/docs/
> 2.0/developers_guide_protocol.html#PostPhotoWithoutMetadata) says...
>
> Thanks in advance
>
> Java / Android Code:
> String dropboxUrl = "http://picasaweb.google.com/data/feed/api/user/
> default/albumid/default<http://picasaweb.google.com/data/feed/api/user/%0Adefault/albumid/default>
> ";
> HttpURLConnection uc = (HttpURLConnection) new URL
> (dropboxUrl).openConnection();
> uc.setDoOutput(true);
> uc.setUseCaches(false);
> uc.setRequestMethod("POST");
> uc.setRequestProperty("GData-Version", "2");
> uc.setRequestProperty("Authorization", "GoogleLogin auth=" +
> authTokenPicasa);
> uc.setRequestProperty("Content-Type", "image/jpeg");
>
> DataOutputStream dataOutput = new DataOutputStream(uc.getOutputStream
> ());
> // binary goes here
> File img = new File("/sdcard/DCIM/pano.jpg");  // sample img-file from
> sdcard
> FileInputStream fin = new FileInputStream(img);
> byte[] buffer = new byte[4096];
> int bytesRead;
>
> while((bytesRead = fin.read(buffer)) != -1){
>         dataOutput.write(buffer, 0, bytesRead);
> }
> dataOutput.flush();
> dataOutput.close();
> fin.close();
>
> if (uc.getResponseCode() == HttpsURLConnection.HTTP_CREATED) {
>    Log.w("Trackalyzer", "PicasaWeb: Photo created");
> } else{
>   Log.w("Trackalyzer", "PicasaWeb: Responsecode: " +
>   uc.getResponseCode()+uc.getResponseMessage());
> }
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Google Picasa Web Albums API" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-picasa-data-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-picasa-data-api?hl=en.
>
>
>


-- 
See me Twitter! http://www.twitter.com/CletusTSJY

http://www.cameronhinkle.com/

"As systems developers, we have selected ourselves into the world of cool,
calming, rational thought.  Either our code compiles, or it doesn't.  The
compiler is never happy for us, nor mad at us.  Perhaps this is why we tend
to apply logic as our main device for resolving disputes." -Peopleware, 2nd
Edition

"Babies...before we're done here...y'all be wearing gold-plated diapers."
-Rock Legend Bruce Dickinson

--

You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums 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-picasa-data-api?hl=en.


Reply via email to