java - 将文件上传到谷歌日历

标签 java google-calendar-api

如何将文件作为附件上传到 Google 日历 Activity ?使用谷歌实验室,您可以在谷歌日历中启用文件上传,但如何将文件上传到java中的日历事件?

http://code.google.com/apis/calendar/data/2.0/developers_guide_java.html

我注意到他们有一个可用于创建/编辑日历事件的 API,但我没有看到任何有关文件上传的信息。谢谢。

最佳答案

来自API developer's guide ,你可以通过setContent方法设置你的CalendarEventEntry的内容:

The entry content is represented by a Content object, a class that can hold either plain text or other forms of content, including XML and binary data. (But the setContent method can also accept a TextConstruct).

然后,使用指南中列出的相同示例,并使用 com.google.gdata.data.OtherContent提供的API的类:

byte[] binaryContent=//... your binary content to attach
OtherContent yourContent=new OtherContent();
yourContent.setBytes(binaryContent);
//don't know if this is mandatory... yourContent.setMimeType(ContentType.ANY);


CalendarEventEntry myEntry = new CalendarEventEntry();

myEntry.setTitle(new PlainTextConstruct("Read the attachment"));
myEntry.setContent(yourContent);

//etc...
DateTime startTime = DateTime.parseDateTime("2006-04-17T15:00:00-08:00");
DateTime endTime = DateTime.parseDateTime("2006-04-17T17:00:00-08:00");
When eventTimes = new When();
eventTimes.setStartTime(startTime);
eventTimes.setEndTime(endTime);
myEntry.addTime(eventTimes);

关于java - 将文件上传到谷歌日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4256531/

相关文章:

java - 编写一个方法用 '%20' 替换字符串中的所有空格?

java - 从一个 pojo 映射多个表

android - 如何从 Activity 中添加 Google 日历中的 Activity ?

安卓 : Showing wrong end date (one day before of actual date) in Google Calendar while adding an event with intent

javascript - Gdata JavaScript Authsub 继续重定向

google-api - 仅一天后 Google 日历 API "The requested minimum modification time lies too far in the past."

java - Collections.min/max 方法的签名

java - 在 Selenium (Java) 中通过 cssSelector 获取元素

java - 导入 Ant 构建脚本时获取 xerces 类的 ClassCastException

javascript - 谷歌日历打印如何工作?