I confirm Base64 data no problem.

Here's code:

logger.fine(newPhoto+"");
logger.fine(newPhoto.getBase64Data().length()+"");
logger.fine(newPhoto.getBase64Data());

PhotoEntry myPhoto = new PhotoEntry();
myPhoto.setTitle(new PlainTextConstruct(newPhoto.getTitle()));
myPhoto.setDescription(new PlainTextConstruct(newPhoto.getDescription
()));
myPhoto.setClient("camix");
byte[] bytes = Base64.decode(newPhoto.getBase64Data()); //Decode
Base64 string


MediaByteArraySource media = new MediaByteArraySource(bytes, "image/
png");
myPhoto.setMediaSource(media);

URL albumPostUrl = new URL("http://picasaweb.google.com/data/feed/api/
user/zhongwangmi/albumid/5336987300048031361");

PhotoEntry photoEntry = getService().insert(albumPostUrl, entry);




debug message:

FINE: POST 
http://picasaweb.google.com/data/feed/api/user/zhongwangmi/albumid/5336987300048031361
May 19, 2009 1:19:52 AM com.google.gdata.client.http.HttpGDataRequest
setHeader
FINER: Content-Type: multipart/related;boundary="----
=_Part_0_10735171.1242695992169"
May 19, 2009 1:19:52 AM com.google.gdata.client.http.HttpGDataRequest
setPrivateHeader
FINER: Authorization: <Not Logged>
May 19, 2009 1:19:52 AM com.google.gdata.client.http.HttpGDataRequest
setHeader
FINER: User-Agent:  lh2 GData-Java/1.31.1(gzip)
May 19, 2009 1:19:52 AM com.google.gdata.client.http.HttpGDataRequest
setHeader
FINER: Accept-Encoding: gzip
May 19, 2009 1:19:52 AM com.google.gdata.client.http.HttpGDataRequest
setHeader
FINER: GData-Version: 1.0
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINE: 400 OK
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: content-type: text/html; charset=UTF-8
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: content-encoding: gzip
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: transfer-encoding: chunked
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: date: Tue
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: date: 19 May 2009 01:19:55 GMT
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: cache-control: private
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: cache-control: must-revalidate
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: cache-control: max-age=0
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: x-content-type-options: nosniff
May 19, 2009 1:19:55 AM com.google.gdata.client.http.HttpGDataRequest
execute
FINER: server: GFE/2.0
May 19, 2009 1:19:55 AM com.nealmi.app.camix.flexservice.ServiceFacade
savePhoto
SEVERE: com.google.gdata.util.InvalidEntryException: OK
Not an image.

com.google.gdata.util.InvalidEntryException: OK
Not an image.

        at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse
(HttpGDataRequest.java:557)
        at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse
(GoogleGDataRequest.java:543)
        at com.google.gdata.client.http.HttpGDataRequest.checkResponse
(HttpGDataRequest.java:535)
        at com.google.gdata.client.http.HttpGDataRequest.execute
(HttpGDataRequest.java:514)
        at com.google.gdata.client.http.GoogleGDataRequest.execute
(GoogleGDataRequest.java:515)
        at com.google.gdata.client.media.MediaService.insert
(MediaService.java:390)


 And  then I copy  base64 string to a file. write an unit test. It's
works fine.

       @Test
        public void testAddPhoto() throws Exception, ServiceException {
                PhotoEntry myPhoto = new PhotoEntry();
                myPhoto.setTitle(new PlainTextConstruct("Puppies FTW"));
                myPhoto.setDescription(new PlainTextConstruct("Puppies are the
greatest."));
                myPhoto.setClient("myClientName");

                URL url = TestAlbumService.class.getResource("");
                File f = new File(url.getFile()+"/java_b64.txt");


                FileReader freader = new FileReader(f);
                BufferedReader reader = new BufferedReader(freader);

                StringBuilder s = new StringBuilder();
                String line= "";
                while((line = reader.readLine()) != null){
                        s.append(line);
                }
                reader.close();
                System.out.println(s.length());

                byte[] b = Base64.decode(s.toString());

                MediaSource byteMedia = new MediaByteArraySource(b, 
"image/png");

                myPhoto.setMediaSource(byteMedia);

                URL albumPostUrl = new 
URL("http://picasaweb.google.com/data/feed/
api/user/zhongwangmi/albumid/5336987300048031361");

PhotoEntry photoEntry = getService().insert(albumPostUrl, entry);
        }


Something wrong?  Please give me some advice. Thanks!

--~--~---------~--~----~------------~-------~--~----~
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