将一堆Google Calendar .ics文件导出到Google云端硬盘上的文件夹 [英] Exporting a bunch of Google Calendar .ics files, to a folder on Google Drive

查看:75
本文介绍了将一堆Google Calendar .ics文件导出到Google云端硬盘上的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Google帐户中有多个日历,我想为其设置定期备份.

I have several calendars in my Google account, for which I would like to set up a periodical back-up.

每个日历都有其.ics文件的特定导出URL,例如 https://calendar.google.com/calendar/exporticalzip?cexp=insert_long_string_of_characters

Each calendar has a specific export URL for its .ics file, e.g. https://calendar.google.com/calendar/exporticalzip?cexp=insert_long_string_of_characters

我想获取每个日历的每个导出链接,并使用某种脚本将文件导出到Google云端硬盘上的指定文件夹(而不是本地计算机)

I'd like to take each export link for each calendar, and have some sort of script that would export the files to a designated folder on my Google Drive (instead of to my local machine)

这有可能吗?

谢谢!

杰米

推荐答案

要获取特定的导出URL,可以使用方法,以按ID获取文件的元数据.在 downloadUrl 下,它具有 exportLinks ,包括(键).检索文件元数据中提供的适当下载URL,然后使用下载URL检索实际文件内容或链接.

To get specific export URL, you can use the method 'Files:get' to get file's metadata by ID. Under the downloadUrl it has the exportLinks including (key). Retrieve the appropriate download URL provided in the file's metadata then retrieve the actual file content or link using the download URL.

要下载文件,请向文件的资源URL发出授权的 HTTP GET 请求,并包含查询参数 alt = media

To download files, you make an authorized HTTP GET request to the file's resource URL and include the query parameter alt=media

GET https://www.googleapis.com/drive/v2/files/0B9jNhSvVjoIVM3dKcGRKRmVIOVU?alt=media
Authorization: Bearer ya29.AHESVbXTUv5mHMo3RYfmS1YJonjzzdTOFZwvyOAUVhrs

private static InputStream downloadFile(Drive service, File file) {
if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) {
try {
HttpResponse resp =
service.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl()))
.execute();
return resp.getContent();
} catch (IOException e) {
// An error occurred.
e.printStackTrace();
return null;
}
} else {
// The file doesn't have any content stored on Drive.
return null;
}
}

有一些Google Doc格式和受支持的导出MIME,请检查以下文档: https://developers.google.com/drive/v2/web/manage-downloads#downloading_google_documents

There are some Google Doc formats and supported export MIME, check this document: https://developers.google.com/drive/v2/web/manage-downloads#downloading_google_documents

这篇关于将一堆Google Calendar .ics文件导出到Google云端硬盘上的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆