从文件集mongodb meteor中检索图像

时间:2017-07-17 13:06:38

标签: mongodb meteor

我使用meteor文件收集包存储图像。我可以在robomongo中看到fs.files和fs.locks。 我面临的问题是检索和显示图像。

我搜索过但只能弄清楚它可以使用我不清楚的图片网址来完成。输入db:

{
"_id" : ObjectId("10d2c609b8911ff5de60d710"),
"length" : 0,
"md5" : "d41d8cd98f00b204e9800998ecf8427e",
"uploadDate" : ISODate("2017-07-17T10:34:58.563Z"),
"chunkSize" : 2096128,
"filename" : "abc.jpeg",
"metadata" : {
    "owner" : "CE6zaYK79uxfdrgbR"
},
"aliases" : [],
"contentType" : "image"

}

db的服务器代码如下:

fc = new FileCollection('fs',  // base name of collection
{ resumable: false,          // Disable resumable.js upload support
resumableIndexName: undefined,    // Not used when resumable is false
chunkSize: 2*1024*1024 - 1024,    // Use 2MB chunks for gridFS and resumable
baseURL: '\gridfs\fs',     // Default base URL for all HTTP methods
locks: {                   // Parameters for gridfs-locks
  timeOut: 360,            // Seconds to wait for an unavailable lock
  pollingInterval: 5,      // Seconds to wait between lock attempts
  lockExpiration: 90       // Seconds until a lock expires
},
http: [ 
    { method: 'get',
    path: '/:md5',  // this will be at route "/gridfs/myFiles/:md5"
    lookup: function (params, query) {  // uses express style url params
      return { md5: params.md5 };       // a query mapping url to myFiles
    }
  }
]    // HTTP method definitions, none by default

} );

0 个答案:

没有答案