想要将电子表格从 Android 应用上传到 Google 文档 - 最佳解决方案是什么?

发布于 2024-09-10 09:17:11 字数 1652 浏览 0 评论 0原文

我想允许我的 Android 应用程序将电子表格文档上传到 Google 文档。使用简单的 Uri 请求:

Uri uri = Uri.parse("http://docs.google.com/DocAction?action=updoc&hl=en");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

此页面在手机上显示为空白(必须使用与手机不兼容的代码)。

我研究了从网络服务上传的 Google 文档程序。它们需要首先对用户进行身份验证并检索 AuthSub 授权,以便在后续 POST 请求(包括 AuthSub 令牌)中使用,以实际上传文档。对于可以保证返回 AuthSub 的 URL 的 Web 服务来说,这很容易,但在手机上又如何呢?

目前我认为我将使用 UrlConnection,使用 getHeader(String) 来获取 AuthSub,然后像这样动态构建整个文档:

POST /feeds/default/private/full HTTP/1.1
Host: docs.google.com
GData-Version: 3.0
Authorization: <your authorization header here>
Content-Length: 73612
Slug: test.xls
Content-Type: application/vnd.ms-excel

<?xml version='1.0' encoding='UTF-8'?>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="4" x:FullColumns="1" x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">IN</Data></Cell>
<Cell><Data ss:Type="String">OUT</Data></Cell>
<Cell><Data ss:Type="String">TIME</Data></Cell>
<Cell><Data ss:Type="String">SUBTOTAL</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Value</Data></Cell>
<Cell><Data ss:Type="Number">123</Data></Cell>
<Cell><Data ss:Type="String">Example</Data></Cell>
<Cell><Data ss:Type="String">Example</Data></Cell>
</Row>
</Table>
</Worksheet>

任何有任何经验或建议的人 - 都希望听到评论。

谢谢,

生锈

I'd like to allow my Android app to upload a spreadsheet document to Google Docs. Using a simple Uri request:

Uri uri = Uri.parse("http://docs.google.com/DocAction?action=updoc&hl=en");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

and this page appears as blank on a phone (must use code not compatible with phones).

I've looked into the Google Docs procedures for uploading from a Web Service. They require first authenticating the user and retrieving an AuthSub authorization to be used in a following POST request (including the AuthSub token) to actually upload the doc. This is easy from a Web Service that can guarantee a URL to return the AuthSub to, but how about on a mobile phone?

Currently thinking that I'll use UrlConnection, use getHeader(String) to grab the AuthSub, then build the entire document dynamically like this:

POST /feeds/default/private/full HTTP/1.1
Host: docs.google.com
GData-Version: 3.0
Authorization: <your authorization header here>
Content-Length: 73612
Slug: test.xls
Content-Type: application/vnd.ms-excel

<?xml version='1.0' encoding='UTF-8'?>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="4" ss:ExpandedRowCount="4" x:FullColumns="1" x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">IN</Data></Cell>
<Cell><Data ss:Type="String">OUT</Data></Cell>
<Cell><Data ss:Type="String">TIME</Data></Cell>
<Cell><Data ss:Type="String">SUBTOTAL</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">Value</Data></Cell>
<Cell><Data ss:Type="Number">123</Data></Cell>
<Cell><Data ss:Type="String">Example</Data></Cell>
<Cell><Data ss:Type="String">Example</Data></Cell>
</Row>
</Table>
</Worksheet>

Anyone with any experience or suggestions - would love to hear a comment.

Thanks,

Rusty

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘你却要生生世世 2024-09-17 09:17:11

在 Google Docs 文档中找到了所有必要的信息。

http://code.google.com/apis/documents/docs/ 3.0/developers_guide_java.html

Found all the info necessary in Google Docs documentation.

http://code.google.com/apis/documents/docs/3.0/developers_guide_java.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文