PyDrive2 icon indicating copy to clipboard operation
PyDrive2 copied to clipboard

Rename google file title

Open hagemouse opened this issue 3 years ago • 7 comments

When I rename the title of a file, I have to do following:

    googlefile = drive.CreateFile({"id": file_id})
    googlefile.FetchMetadata(fields="title")
    googlefile["title"] = new_title
    googlefile.Upload()

Not like the example, I need to add:

    googlefile.FetchMetadata(fields="title")

hagemouse avatar Feb 26 '21 17:02 hagemouse

@hagemouse could you please try the PyDrive (the old one repo)? I wonder if it is a regression of some sort?

shcheklein avatar Feb 27 '21 00:02 shcheklein

Just gave me following:

pydrive.files.ApiRequestError: <HttpError 404 when requesting https://www.googleapis.com/drive/v2/files/vx5FvnY2qrRJpGNhmRg?fields=title&alt=json returned "File not found"

Even if i tried this:

    file =drive.CreateFile({"id":file_id,
                            'corpora': "teamDrive",
                            'teamDriveId': dirve_id,
                            'includeTeamDriveItems': "true",
                            'includeItemsFromAllDrives': "true",
                            'supportsTeamDrives': "true",
                            'supportsAllDrives': "true"})
    file.FetchMetadata(fields="title") #here 404 happened
    file["title"]= new_title
    file.Upload()

hagemouse avatar Feb 27 '21 05:02 hagemouse

@hagemouse could you try the same with a regular, your own drive, to avoid dealing with team and shared drives? (to avoid 404)

shcheklein avatar Feb 28 '21 21:02 shcheklein

I tried it using pydrive on my own drive, and also need to add following:

file.FetchMetadata(fields="title")

hagemouse avatar Feb 28 '21 23:02 hagemouse

@hagemouse thanks! it helps. It's not a regression then. I found the code that is responsible for this. Now we need to understand if it's a bug of should we just fix the example.

shcheklein avatar Mar 01 '21 04:03 shcheklein

Related https://github.com/googleworkspace/PyDrive/issues/101

shcheklein avatar Mar 01 '21 04:03 shcheklein

Ok. Thanks.

hagemouse avatar Mar 01 '21 04:03 hagemouse