gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 05:52:24 25 4
gpt4 key购买 nike

如何将文件作为附件上传到 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com