1313import java .io .IOException ;
1414import java .io .InputStream ;
1515import java .io .OutputStream ;
16+ import java .sql .Date ;
1617
1718// JavaCommons imports
1819import picoded .core .common .EmptyArray ;
@@ -528,7 +529,9 @@ public void backend_ensureFolderPath(final String oid, final String folderPath)
528529 * @return DataObject created timestamp in ms
529530 */
530531 public long backend_createdTimestamp (final String oid , final String filepath ) {
531- return -1 ;
532+
533+ // Currently only modified timestamp is supported
534+ return backend_modifiedTimestamp (oid , filepath );
532535 }
533536
534537 /**
@@ -543,6 +546,22 @@ public long backend_createdTimestamp(final String oid, final String filepath) {
543546 * @return DataObject created timestamp in ms
544547 */
545548 public long backend_modifiedTimestamp (final String oid , final String filepath ) {
549+ // Lets build the query for the "root file"
550+ Bson query = Filters .eq ("filename" , fullpath );
551+
552+ // Lets prepare the search
553+ GridFSFindIterable search = gridFSBucket .find (query ).limit (1 );
554+
555+ // Lets iterate the search result, and return true on an item
556+ try (MongoCursor <GridFSFile > cursor = search .iterator ()) {
557+ if (cursor .hasNext ()) {
558+ GridFSFile fileObj = cursor .next ();
559+ Date uploadDate = fileObj .getUploadDate ();
560+ return uploadDate .getTime ();
561+ }
562+ }
563+
564+ // Fail, as the search found no iterations
546565 return -1 ;
547566 }
548567
0 commit comments