Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2546

GridFSBucket requires key filename

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.0
    • Affects Version/s: 3.4.2
    • Component/s: GridFS
    • None

      The spec for GridFS mentions that filename is optional. However, the Java driver GridFSBucket seems to require this field.

      For example, this fs.files collection using GridFS (note the missing filename field):

      > db.fs.files.find()
      {
        "_id": ObjectId("5950700998e91439516f0abe"),
        "chunkSize": 261120,
        "uploadDate": ISODate("2017-06-26T02:23:05.529Z"),
        "length": 8466,
        "md5": "c09d698b0e623e5cc05cb05d49002a2d"
      }
      

      This Java code snippet will fail to download the file:

      GridFSBucket bucket = GridFSBuckets.create(database);
      bucket.downloadToStream(new ObjectId("5950700998e91439516f0abe"), System.out);
      

      The error displayed is:

      org.bson.BsonInvalidOperationException: Document does not contain key filename
      

      However the same code in Python will work:

      fs = gridfs.GridFSBucket(conn.test)
      print fs.open_download_stream(bson.ObjectId("5950700998e91439516f0abe")).read()
      

      There seems to be a discrepancy in GridFS behaviour between the Java driver and the Python driver.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            kevin.adistambha@mongodb.com Kevin Adistambha
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: