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

GridFSBucket requires key filename

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.4.2
    • Fix Version/s: 3.5.0
    • Component/s: GridFS
    • Labels:
      None
    • Sprint:
      JVM Sprint 40

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: