views:

121

answers:

0

I have a media source object

     MediaStreamSource ms = new MediaStreamSource(is, mediaType);
 AttachmentEntry newAttachment = new AttachmentEntry();

and try to insert it and in case it already exists then update it instead of insert.

 try
 {
  return service.insert(new URL(getContentFeedUrl()), newAttachment);
 }
 catch (VersionConflictException  ve) {
  //update version directly
  return service.updateMedia(new URL(getContentFeedUrl()), newAttachment);
 }

But when I do so I get following stack trace

org.apache.commons.fileupload.FileItemStream$ItemSkippedException
at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:880)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at com.google.gdata.data.media.MediaSource$Output.writeTo(MediaSource.java:87)
at com.google.gdata.data.media.MediaBodyPart$MediaSourceDataHandler.writeTo(MediaBodyPart.java:74)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:452)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:157)
at com.google.gdata.wireformats.output.media.MediaMultipartGenerator.generate(MediaMultipartGenerator.java:58)
at com.google.gdata.wireformats.output.media.MediaMultipartGenerator.generate(MediaMultipartGenerator.java:37)
at com.google.gdata.client.Service.writeRequestData(Service.java:1831)
at com.google.gdata.client.media.MediaService.updateMedia(MediaService.java:497)
at morefile.UploadApp.uploadAttachment(UploadApp.java:105)