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";
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].
For more options, visit this group at 
http://groups.google.com/group/google-picasa-data-api?hl=en.


Reply via email to