从gdata API读取文档的内容?

编程入门 行业动态 更新时间:2024-10-11 21:23:41
本文介绍了从gdata API读取文档的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Java库来访问gdata api.我只希望能够打印文档的内容.我设置了项目以列出Feed中的所有文档,现在我有了一个文档列表,我想打印其内容:

I'm using the java library to access the gdata api. I just want to be able to print the contents of a document. I setup my project to list all the docs in my feed, now that I have a document listing, I want to print its contents:

for (DocumentListEntry entry : feed.getEntries()) { // Ok, how do we print the doc's contents now? entry.getContents(); }

似乎我们应该从条目中获取URL,然后自己读取URL上的内容.我发现一则帖子指出,这就是我们获取该网址的方式:

It looks like we're supposed to get the URL from the entry, then read the contents at the URL ourselves. I found a post stating that this is how we get that URL:

MediaContent content = (MediaContent)entry.getContent(); String url = content.getUri();

但是当我尝试从中读取内容时,我收到了一个HTML响应,说此内容已移动".我读到这是因为我们必须验证我们的http-read方法,但是我不确定该怎么做.真的没有内置的方法可以做到这一点吗?

but when I try to read from it, I get an html response saying 'this content has moved'. I read that this is because we have to authenticate our http-read method, but I'm not sure how to do that. Is there really no built-in way to do this?

谢谢

推荐答案

MediaContent content = (MediaContent) entry.getContent(); MediaSource source = docService.getMedia(content); InputStream in = source.getInputStream();

更多推荐

从gdata API读取文档的内容?

本文发布于:2023-11-28 16:27:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643126.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文档   内容   gdata   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!