[英]Accessing Google Drive Files in Google App Engine [Shareable Link]
I have an android app that saves an image into the Google Drive and shares the weblink to my Google App Engine server (python). 我有一个Android应用程序,可将图像保存到Google云端硬盘中,并共享与我的Google App Engine服务器(python)的网络链接。
// Create client
mGoogleApiClient = new GoogleApiClient.Builder(mContext)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
// handling results after uploading
final DriveOperationResult<Metadata> driveOperationResultHandler = new DriveOperationResult<Metadata>() {
@Override
public void onDriveOperationSucceeded(Metadata result) {
try {
// Successfully fetched metadata
onSuccess(driveId,
result.getOriginalFilename(),
result.getWebContentLink(),
result.getWebViewLink(),
result.getAlternateLink(),
result.getEmbedLink());
} finally {
mGoogleDriveClient.disconnectAsync();
}
}
Note: result.getEmbedLink() always returns null. 注意: result.getEmbedLink()始终返回null。 Also, result.getAlternateLink() and result.getWebContentLink() are not accessible. 另外,result.getAlternateLink()和result.getWebContentLink()不可访问。 I am using Google Drive Android API. 我正在使用Google Drive Android API。
I need to post the link to another server from the google app engine. 我需要将链接从Google App引擎发布到另一台服务器。 How do I get a shareable link from google app engine [python] or android? 如何从Google App Engine [python]或android获取共享链接?
or 要么
How do I change the permission on the link so that anyone with the link can read? 如何更改链接的权限,以便具有链接的任何人都可以阅读?
In python, you must do something like this 在python中,您必须执行以下操作
@decorator.oauth_required
def get(self):
try:
http = decorator.http()
service = discovery.build("drive", "v2", http=http)
# Make the list of every files in the user's Drive
# Take every fields we will need after
fields = "items(id,title,,alternateLink)
list = service.files().list(fields=fields).execute()
Then use the alternateLink property to get a link that can be shared for opening the file in the relevant Google editor or viewer 然后,使用alternateLink属性获取可以共享的链接,以在相关的Google编辑器或查看器中打开文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.