google drive API允许重复? [英] google drive API allows duplicates?

查看:165
本文介绍了google drive API允许重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用范围
' https: //www.googleapis.com/auth/drive.file '

令人惊讶的是,api允许我将具有相同标题的多个文件上传到同一个文件夹如果我在网络浏览器中浏览我的谷歌浏览器,我甚至可以看到这些重复的文件。

Surprisingly, the api allows me to upload multiple files with the exact same title into the same folder. I can even see these duplicate files if I browse over to my google drive in my web browser.

有没有什么办法可以让API阻止文件名中的重复?我可以检查一个文件的存在,然后上传另一个同名的文件,但这似乎是一种奇怪的方式来处理文件系统的写入...

Is there any way I can have the API prevent duplicates in filenames? I could check for a file's existence before uploading another with the same name, but that seems to be a strange way to handle writing to a file system...

推荐答案

有什么办法可以让API阻止文件名中的重复。

在驱动器中,文件由其ID唯一标识。属性(如名称(Title)),父目录,权限,描述都是简单的属性。它的工作原理很好。

No. In Drive, files are uniquely identified by their ID. Attributes such as name (aka Title), parent directories, permissions, description, are simply attributes. It works rather well.

请记住,Drive是关于设备之间的同步,例如。您的电脑,Android手机,Chromebook等。如果Drive通过名称识别哪个文件,那么Drive会如何跟踪哪个文件,通常会被重命名。例如。我的驱动器上有一个名为Foo的文件,同步到我的Android手机,我将该文件重命名为Bar。如果标题是标识符,我的Android手机会将其看作是一个新文件。因为ID是(不可变)的标识符,而标题只是一个属性,所以Android可以更新标题属性而不会困惑。

Remember that Drive is all about synchronisation between devices, eg. your pc, your Android phone, your Chromebook, etc. How would Drive keep track of which file was which if it identified them by name, which will often get renamed. Eg. I have a file called "Foo" on Drive, synced to my Android phone, and I rename that file to "Bar". If title was the identifier, my Android phone would see that as a new file. Because ID is the (immutable) identifier, and title is merely an attribute, Android can update the title attribute without getting confused.

这篇关于google drive API允许重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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