I'm creating a folder (New Folder) inside a given one (FooFolder). If I use "writer" as permission role everything is ok.
My Drive
|->FooFolder
|->NewFolder
I have this three functions:
function fileCreation($service, $fileName, $emailToOwn, $type )
{
//Create the file
$file = new Google_Service_Drive_DriveFile();
$file->setTitle($fileName);
$file->setMimeType($type);
$file = $service->files->insert( $file );
$permission = insertPermission($service, $file->getId(),$emailToOwn,"user","writer");
return $file;
}
function insertPermission($service, $fileId, $value, $type, $role) {
$newPermission = new Google_Service_Drive_Permission();
$newPermission->setValue($value);
$newPermission->setType($type);
$newPermission->setRole($role);
return $service->permissions->insert($fileId, $newPermission, array(NULL,false));
}
function insertFileIntoFolder($service, $folderId, $fileId) {
$newChild = new Google_Service_Drive_ChildReference();
$newChild->setId($fileId);
try {
return $service->children->insert($folderId, $newChild);
} catch (Exception $e) {
print "An error occurred: " . $e->getMessage();
}
return false;
}
When I change permission role to "Owner" the new folder is both created correctly in the parent directory and displayed in the root folder.
A link to a picture of my drive after the call of $service->permissions->insert($fileId, "owner");
A link to a picture of my drive after the call of $service->permissions->insert($fileId, "writer");