Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google drive API allows duplicates?

I am trying to create folders using google drive API using the scope 'https://www.googleapis.com/auth/drive.file'

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.

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...

like image 803
yegodz Avatar asked Jan 29 '15 12:01

yegodz


1 Answers

"Is there any way I can have the API prevent duplicates in filenames?"

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.

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.

like image 78
pinoyyid Avatar answered Oct 14 '22 07:10

pinoyyid