Skip to content

Commit

Permalink
GridFS Upload Problem with 4.2 driver found
Browse files Browse the repository at this point in the history
  • Loading branch information
sfxcode committed Apr 29, 2021
1 parent 8b11e9b commit 3ab39ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

## Versions

### 2.2.3
* rollback to mongo-scala-driver [4.1.2](https://mongodb.github.io/mongo-java-driver/4.2/driver-scala/) because of critical bug in GridFS Upload

### 2.2.2
* mongo-scala-driver [4.2.3](https://mongodb.github.io/mongo-java-driver/4.2/driver-scala/)

Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ libraryDependencies += "joda-time" % "joda-time" % "2.10.10" % Test

libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.11" % Test

libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "4.2.3"
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "4.1.2"

libraryDependencies += "org.xerial.snappy" % "snappy-java" % "1.1.8.4" % Provided

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.bson.types.ObjectId
import org.specs2.mutable.Specification
import org.specs2.specification.BeforeAll

import scala.io.Source

class GridFSDatabaseSpec extends Specification with GridfsDatabaseFunctions with BeforeAll {

"GridFSDatabase" should {
Expand All @@ -20,12 +22,12 @@ class GridFSDatabaseSpec extends Specification with GridfsDatabaseFunctions with

}



"insert file and in" in {
val fileName = "scala-logo.png"

val oid: ObjectId = insertImage(ImageDAOSourcePath + fileName, ImageMetadata("template1", group = "templates"))
val filePath = ImageDAOSourcePath + fileName
val oid: ObjectId = insertImage(filePath, ImageMetadata("template1", group = "templates"))
val uploadBytes = File(filePath).bytes.toList

val file = findImage(oid)
file.getFilename must be equalTo fileName
Expand All @@ -39,7 +41,14 @@ class GridFSDatabaseSpec extends Specification with GridfsDatabaseFunctions with

result must not be equalTo(-1)

File(downloadPath).exists must beTrue
val downloadedFile = File(downloadPath)
downloadedFile.exists must beTrue

val downloadBytes = File(downloadPath).bytes.toList

downloadBytes.size must be equalTo uploadBytes.size

downloadBytes must be equalTo uploadBytes

}

Expand Down

0 comments on commit 3ab39ea

Please sign in to comment.