Paul Gestwicki
unread,May 31, 2011, 2:47:04 PM5/31/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to gdata-java-client
I am writing a program to upload jars to GoogleSites for use in JNLP.
It works fine right now, always pushing the latest build up to
GoogleSites. I am trying to add a feature whereby the jar is only
uploaded if it's newer than the one that's up there. The best
heuristic I could come up with to try is to check if the file sizes
are different---not perfect, but good enough.
My existing, working code:
public static AttachmentEntry updateFile(AttachmentEntry entry, File
newFile)
throws IOException, ServiceException {
entry.setMediaSource(new MediaFileSource(newFile, mediaTypes
.getContentType(newFile)));
return entry.updateMedia(true);
}
I tried doing a check on file size like this:
public static AttachmentEntry updateFile(AttachmentEntry entry, File
newFile)
throws IOException, ServiceException {
long attachmentSize = entry.getMediaSource().getContentLength();
long fileSize = newFile.length();
System.out.println("--- attachment size: " + attachmentSize
+ ", file size: " + fileSize + "\n --> They are "
+ (attachmentSize == fileSize ? "equal" : "unequal"));
entry.setMediaSource(new MediaFileSource(newFile, mediaTypes
.getContentType(newFile)));
return entry.updateMedia(true);
}
However, getMediaSource returns null for all the attachments on the
filecabinet page, including the .jar and .jnlp files that are there.
Am I not using getMediaSource correctly, or is there another way to
accomplish my goal?