Hey everyone,
I’m working on a project with the Google Docs API in Python. I’ve been using the metadata description field to store the original file date and time. But I noticed something interesting when I used the Google Drive client app.
It seems to keep the original timestamp of uploaded files, and I can see this info through the Google Docs API. Now I’m wondering if there’s a way to set the file date and time directly using the API.
Has anyone figured out how to do this? It would be super helpful for my project. I’ve looked through the docs but couldn’t find anything clear on this.
Any tips or ideas would be awesome. Thanks in advance!
I’ve been down this rabbit hole before, and it’s a tricky one. Google doesn’t expose a direct way to set the original timestamp through the API, which can be frustrating when you’re trying to maintain file integrity.
One unconventional method I stumbled upon was using the ‘createdTime’ field in combination with a custom property. When creating the file, set the ‘createdTime’ to your desired original timestamp. Then, immediately update the file with a custom property to store the actual creation time.
This approach lets you maintain both the original and actual timestamps. It’s a bit hacky, but it’s worked well in my projects where preserving file history was crucial.
Keep in mind, this method requires careful handling to ensure you don’t accidentally overwrite the ‘createdTime’ in subsequent updates. It’s not perfect, but it might be worth exploring for your specific use case.
hey dave, i’ve messed with this too. google’s api is weird about timestamps. what i did was use a custom property field to store the original date. it’s not perfect but it works. you could try that or maybe play with the ‘viewedByMeTime’ field. just ideas tho, good luck!
I’ve actually encountered a similar issue while working with the Google Docs API. From my experience, setting the original timestamp directly through the API isn’t straightforward. Google seems to handle this internally when files are uploaded through their client apps.
One workaround I found is to use the ‘modifiedTime’ field in the file metadata. You can set this to your desired timestamp when creating or updating a file. It’s not exactly the same as the original upload time, but it might serve your purpose.
Another option is to store the original timestamp in a custom property. This way, you can retrieve it later without affecting the file’s metadata. It’s not ideal, but it’s a reliable method I’ve used in my projects.
Have you considered these approaches? They might not be perfect solutions, but they could be useful alternatives for your project.