Beginning Sept. 30, 2020, you will no longer be able to place a file in multiple parent folders; every file must have exactly one parent folder location. Instead, you can use a combination of status checks and a new shortcut implementation to accomplish file-related operations.
Add a parent folder to a file
To add a parent folder to a file:
Call
files.get()
orfiles.list()
on the file and check thecanAddMyDriveParent
field to ensure the file doesn't have any parents.If
canAddMyDriveParent
returnstrue
, callfiles.update()
, with theaddParents
field set to the new parent folder's ID and theenforceSingleParent
set totrue
, to add a parent folder for the file.If
canAddMyDriveParent
returnsfalse
, all current parent folders are removed and a new parent folder is added.
Create a file in multiple parent folders
With the new model, you cannot create a file in multiple parent folders. Instead, you can create the file in one parent folder and use shortcuts in the other parent folders:
Call
files.create()
(v3),files.insert()
(v2), orfiles.copy()
withenforceSingleParent
field set totrue
to create a file in a single parent.Create a shortcut in each additional parent. For information about creating shortcuts, refer to Create a shortcut to a Drive file.
Move a file to another parent folder
Under the new model, the current user must have share access to a file to move it. To move a file to from one location to another:
Call
files.get()
orfiles.list()
on the file and check thecanMoveItemWithinDrive
field.If
canMoveItemWithinDrive
returnstrue
, callfiles.update()
with:- the
removeParents
field set to the current parent folder's ID. - the
addParents
field set to the new parent folder's ID - the
enforceSingleParent
field set totrue
If
canMoveItemWithinDrive
returnsfalse
, you can create a shortcut in the new location. For information about creating shortcuts, refer to Create a shortcut to a Drive file.- the
For more information on moving files, refer to Move files between folders.