How to send back a file as a ring-response using monger?

42 Views Asked by At

Using find-by-id monger api like (prn (gfs/find-by-id fs id)) gives:

#object[com.mongodb.gridfs.GridFSDBFile 0x5742d15e "{ \"metadata\" : { \"format\" :  null } , \"filename\" : \"blob\" , \"aliases\" :  null  , \"chunkSize\" : 261120 , \"uploadDate\" : { \"$date\" : \"2020-03-05T23:36:50.249Z\"} , \"length\" : 55602 , \"_id\" : { \"$oid\" : \"5e618d125815506bb3c72cfe\"} , \"contentType\" :  null  , \"md5\" : \"48284ab9cc81e2d079af703f5aed3267\"}"]

This is how I'm sending this file to the client with wrap-edn middleware enabled:

  {:status (or status 200)
   :headers {"Content-Type" "application/edn"}
   :body (pr-str (gfs/make-input-file fs (gfs/find-by-id fs id)))}

However, this gives the following in the client:

Invalid symbol: java.lang.IllegalArgumentException:.  Format should have been EDN", :original-text "java.lang.IllegalArgumentException: No implementation of method: :to-input-stream of protocol: #'monger.gridfs/InputStreamFactory found for class: com.mongodb.gridfs.GridFSDBFile\n\tat 
0

There are 0 best solutions below