[GODRIVER-2058] Allow setting uploadDate on gridfs upload file Created: 23/Jun/21 Updated: 10/Aug/21 Resolved: 10/Aug/21 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | GridFS |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Ed Pelc | Assignee: | Benji Rewis (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | feature, mgocompat, post-5.0 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
You should be able to set the `uploadDate` field when opening a gridfs upload stream. Right now it always uses `time.Now()`. I believe you'd want to add this as a method like `options.GridFSUpload().SetUploadDate()`.
The old mgo driver use to allow this iirc and either way it is useful for controlling more aspects of gridfs files instead of having to stick it in metadata. |
| Comments |
| Comment by Benji Rewis (Inactive) [ 10/Aug/21 ] |
|
Elaborated in the documentation for UploadDate. Thanks again for your report epelc@greatcloak.com! The associated DOCSP ticket is listed as "Open". |
| Comment by Githook User [ 10/Aug/21 ] |
|
Author: {'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}Message: |
| Comment by Benji Rewis (Inactive) [ 30/Jul/21 ] |
|
Hello again epelc@greatcloak.com! That sounds like a plan. Here's an addition to our current documentation in the Go driver: https://github.com/mongodb/mongo-go-driver/pull/711. I've filed an internal documentation ticket to request that https://docs.mongodb.com/manual/core/gridfs/ be updated, but because the documentation project is internal you might not be able to see it in the Issue Links off of this ticket. I'll talk to the docs team about updating the security level and make sure to keep you abreast of any possible changes to the official documentation. |
| Comment by Ed Pelc [ 29/Jul/21 ] |
|
Hi Benji, Thanks for working on this. I think it's ok to keep it readonly but I'd strongly request it be documented in the go driver and also on the official gridfs docs. Basically something saying the drivers manage this field and it is explicitly meant to be read only/set by the driver at file upload time(also recommend using the metadata field to store your own date). https://docs.mongodb.com/manual/core/gridfs/ I think if the drivers are going to take that stance it should be written down prominently to help avoid people potentially going down a rabbit hole. |
| Comment by Benji Rewis (Inactive) [ 28/Jul/21 ] |
|
Hello again epelc@greatcloak.com. The associated drivers ticket (DRIVERS-1845), which was a feature request to consider making the uploadDate field configurable as a cross-drivers change, has been closed. In short, they've suggested that users in your position make use of the metadata field, described here in cross-drivers specifications and available here in the Go driver. The uploadDate would still contain the time the file was uploaded to GridFS, but the metadata field could hold the actual upload date from the third-party storage system. Let us know if that still introduces a lot of friction to your migration from mgo, and we can certainly brainstorm other workarounds. |
| Comment by Benji Rewis (Inactive) [ 13/Jul/21 ] |
|
Hello epelc@greatcloak.com ! Thanks again for your feature request. Your case sounds totally reasonable, and we’d like to make your migration from mgo as seamless as possible. The GridFS API is defined by a cross-drivers specification, and it currently requires that uploadDate be the current time when a file is uploaded. So, I’ve created DRIVERS-1845 to consider making that field configurable as a cross-drivers change. |
| Comment by Ed Pelc [ 07/Jul/21 ] |
|
Hi Matt,
|
| Comment by Matt Dale [ 07/Jul/21 ] |
|
Hey epelc@greatcloak.com thanks for this feature request! I have a few questions to help us better understand your use case for setting an alternate uploadDate value.
Unfortunately, we won't be able to pick up any feature requests until the MongoDB Server v5.0 release on July 13th. Thanks for your patience! |
| Comment by Ed Pelc [ 23/Jun/21 ] |
|
This would be where it'd be used internally. `createFilesCollDoc` |