Migrate your app to the single-parent model

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:

  1. Call files.get() or files.list() on the file and check the canAddMyDriveParent field to ensure the file doesn't have any parents.

  2. If canAddMyDriveParent returns true, call files.update(), with the addParents field set to the new parent folder's ID and the enforceSingleParent set to true, to add a parent folder for the file.

    If canAddMyDriveParent returns false, 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:

  1. Call files.create() (v3), files.insert() (v2), or files.copy() withenforceSingleParent field set to true to create a file in a single parent.

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

  1. Call files.get() or files.list() on the file and check the canMoveItemWithinDrive field.

  2. If canMoveItemWithinDrive returns true, call files.update() with:

    • theremoveParents field set to the current parent folder's ID.
    • theaddParents field set to the new parent folder's ID
    • the enforceSingleParent field set to true

    If canMoveItemWithinDrive returns false, you can create a shortcut in the new location. For information about creating shortcuts, refer to Create a shortcut to a Drive file.

For more information on moving files, refer to Move files between folders.