This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Change picture in Google app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Change picture in Google app" Watch "Change picture in Google app" New topic
Author

Change picture in Google app

Bhanuprasad saketi
Greenhorn

Joined: Aug 15, 2012
Posts: 8
hi i am working with google app and java .in my project my present task is change picture in google app.i am writing like this

String url="https://www.google.com/m8/feeds/profiles/domain/"+ sDomain + "/full/pcvita1111qaeteam10?xoauth_requestor_id=appsadmin@soharcoas.com" ;
ContactEntry profile = contactService.getEntry(
new URL(url),
ContactEntry.class);
String filepath="C:\\Users\\bhanuprasad\\Documents\\Downloads\\549002_459129587462191_1689883124_n.jpg";
File file = new File(filepath);
FileInputStream in=new FileInputStream(file);
System.out.println((byte)in.getChannel().size());
byte[] photoData = new byte[(int) file.length()];
System.out.println(photoData);
Link photoLink = profile.getContactPhotoLink();
System.out.println(photoLink);
URL photoUrl = new URL(photoLink.getHref());
System.out.println(photoUrl);



GDataRequest request = contactService.createRequest(GDataRequest.RequestType.UPDATE,
photoUrl, new ContentType("image/*"));

request.setEtag(photoLink.getEtag());
System.out.println(photoLink.getEtag());
OutputStream requestStream = request.getRequestStream();
requestStream.write(photoData);
request.execute();

but i got the follwing exception
com.google.gdata.util.InvalidEntryException: Bad Request
Invalid image file

at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:594)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
at com.cloudcodes.TestOU.main(TestOU.java:137)
Bad Request
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4167
    
  21

Can you please UseCodeTags when you post next time.

It looks like you create a byte[] named photoData, but never fill it with data. You then try to send that empty byte[] as an image, but because it does not have image bytes in it the request fails. You need to fill photoData with data from a photo.


Steve
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4167
    
  21

Bhanuprasad saketi wrote:


Here is your code in tags
Bhanuprasad saketi
Greenhorn

Joined: Aug 15, 2012
Posts: 8
Hi thanks for the replay
I have on more doubt in my project i want to wish the user BirthDay's .I am working with google app and java .alreay the user BirthDay date is store in googleapp now i want to compare the date to sysdate if month and date is equal i want to send the BirthDay wishes to user in my database i have 2000 records how to write the code please help me.
Bhanuprasad saketi
Greenhorn

Joined: Aug 15, 2012
Posts: 8
Hi Thanks for the Replay
In my project i upload one image by using <input type='file'> but before uploading the file in google app blob i want to check the image height and wedith means only 98*68 images only i want to upload other than the 98*68 i want to show the error message .how can do this by using javascript or java or jquery ?
Bhanuprasad saketi
Greenhorn

Joined: Aug 15, 2012
Posts: 8
Hi Thanks for the replay in my project i want to show the information in next 7days means if there is any birthday for next 7days i want to show those birthdays .in my project i ma using google app and java .how can i write this code please help me urgent in my project.
Bhanuprasad saketi
Greenhorn

Joined: Aug 15, 2012
Posts: 8
Hi Thanks for the replay..
in my project i want to show the users information into to one csv file i have 2000 records and i am using google app .I red one tutorial we can't write the files in google app so how can i do my task please help me
 
 
subject: Change picture in Google app
 
Similar Threads
error in dwonloading a pdf file
datastream with additional parameter
PDF file display on the browser
file downloader for image downloading not upto the limit....
Saving Text file at runtime