Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
122 views
in Technique[技术] by (71.8m points)

Creation Date PDF Google Drive

I want to change the creation date on a Google Drive PDF file. So, how can I achieve this?

public static File SetLastModified(string fileID, DateTime lastModified)
{
    File file = DriveService.Files.Get(fileID).Fetch();
    file.ModifiedDate = lastModified.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fff'Z'");
    try
    {
        FilesResource.UpdateRequest request = DriveService.Files.Update(file, fileID);
        request.SetModifiedDate = true;
        file = request.Fetch();
    }
    catch (Exception e)
    {
        throw;
    }
    return file;
}
question from:https://stackoverflow.com/questions/65849469/creation-date-pdf-google-drive

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It is not possible to change the creation date of a file using Files:update() method

If you will check the request body for Files:update() , you can only modify the parameters listed in the table provided in the document. createdTime property is not included in the list.

enter image description here

The one being modified in your sample code is the modifiedTime property which is included in the list of editable properties.


If you want to have a file with a specified createdTime, you need to create a new file using Files:create(). createdTime can be modified as part of the request body

enter image description here


Additional Reference:

Drive API Quickstart - Setup Drive API for different platforms

Drive API - How to create Files


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...