想要将电子表格从 Android 应用上传到 Google 文档 - 最佳解决方案是什么?
我想允许我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 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