#mongodb #mongodb-query #aggregation-framework
Вопрос:
Я попытался выполнить следующий запрос, но он не удался
db.getCollection('images').aggregate([
{
$project: {
"practiceId": "$practiceId",
"imageSize": { $binarySize: "$data" }
}
}])
И мои примерные данные в mongodb выглядят так
{
"_id" : ObjectId("60be3c9ea77d6312514276384"),
"_class" : "com.test.images.model.ImageEntity",
"practiceId" : NumberLong(242),
"fileName" : "img.jpg",
"contentType" : "image/jpeg",
"data" : { "$binary" : "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTExMVFhUVFyAYFRcXFxsgIBggICggICAoHx8gJTAqICYxJR8fKjsrMTU3NTU1ICs7QDo1PzA1NjUBCgoKDg0OFxAQFjgdFhorNCsvKys3Ky0rNyszKzctLTMyLS03NzcrLS0rNzc3Kys4KzgrODgrKzg4NjctNy81MP/AABEIAMgAyAMBIgACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAABAUCAwYBB//EADwQAAEDAgQDBQUGBQQDAAAAAAEAAhEDIQQSMUEFUWEGEyJxgTKRobHBB0JSYtHwIzNy4fEUgpLSY6Ky/8QAGQEBAAMBAQAAAAAAAAAAAAAAAAECAwQF/8QAJBEBAQACAgICAgIDAAAAAAAAAAECAxEhEjEEUUFxMoETImH/2gAMAwEAAhEDEQA/APuKIiAiIgIiICIqHtjxr/S0C4HxOs3npJj9evoQce7U0cPLZDnjVo281wvFO11d4zF2UH2GNnTqOfn8FzArPdme /i8UyZJHXXn7lDe9zjlFOTzMlZ3Jrjhz6WNLiFR7iS4Hq9x WZTBxFtNwOhB2cSD6mY8tPgoVPhVVwAawNG8mPcBorXC9nrS8/5WN24xvj8fK/h0vZ/7QKfsVZtuTJHruPjzXc4TF06rc1NwcOYXxPF9nHgksI9LLoewfFXMf3TgQZ066e/4LTDZKy2abj7fU0WLTIWS2YCIiAiIgIiICIiAiIgIiICIiAiIgLgPtJYX1KbPuimXeuYAfvou/XJds8MCc3OnlHvn9 aipnt8yNIlvdxADpHMg/sK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fXuuD55xwB1JzTur/AOzTi/e4c0XumpQOW pYfZ91x6Dms J9mqTmnI57Z2zTHlmm3T3RoeMoYbF8NxTK0CpSnK8ssXNOog2nQi8SAq69OWN67jTZuwzx q uPCxLllTqBzQ5plrgC0jcG4QhbOZrL16Hr0tWJpogcjXSvMpWD6Z1BhShk52ysAFW4cEuAN4uVZquS2IiIqrCIiAiIgpOPs8TT0 X VS1TdEWk9M8vbbh3K3olEUoSA4IXrxFCXmYr3MiKRm0BZQERQPHAQudpPaS6g8jUinO8/dP093JEVsUVa8EYKdPu5s1xyg7A3j3ypzqo5hEVb3Vp6a3Ylo3Wt2NaNwiJwjlpfxRnO/S/wAkompVNrDclES9QndWuGw4YIHqea3IizaCIiD/2Q==", "$type" : "00" },
"thumbnail" : false
}
Есть какие-нибудь предложения?
Ответ №1:
Возможно, проблема с форматом данных. Этот работает:
db.images.insertOne({
"_class": "com.test.images.model.ImageEntity",
"practiceId": NumberLong(242),
"fileName": "img.jpg",
"contentType": "image/jpeg",
"thumbnail": false,
data: BinData(0, "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTExMVFhUVFyAYFRcXFxsgIBggICggICAoHx8gJTAqICYxJR8fKjsrMTU3NTU1ICs7QDo1PzA1NjUBCgoKDg0OFxAQFjgdFhorNCsvKys3Ky0rNyszKzctLTMyLS03NzcrLS0rNzc3Kys4KzgrODgrKzg4NjctNy81MP/AABEIAMgAyAMBIgACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAABAUCAwYBB//EADwQAAEDAgQDBQUGBQQDAAAAAAEAAhEDIQQSMUEFUWEGEyJxgTKRobHBB0JSYtHwIzNy4fEUgpLSY6Ky/8QAGQEBAAMBAQAAAAAAAAAAAAAAAAECAwQF/8QAJBEBAQACAgICAgIDAAAAAAAAAAECAxEhEjEEUUFxMoETImH/2gAMAwEAAhEDEQA/APuKIiAiIgIiICIqHtjxr/S0C4HxOs3npJj9evoQce7U0cPLZDnjVo281wvFO11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JimT3db h2h/2ug RcN19DIWurZ5Y/9Y7tfhl16YQoxwFK38NljI8I156a3N1KRa8SsubGLRGiZVkiIeJC8leyg8ZUgqaoTmqWw2HkoyTGSIiqsIiICxc2QQd7LJEHJ1W 006tK1YauWnop3FWZap5Ov8Aqq1wvC0jKugbMAjdZgkbKs4dii3wm42Vm2t0RLY2qD0PIrMDda5WUqEvK9IOEH06KIcCdnX6hTWr2VW4S 4vM7PVcLS4BWa5kurPNPxAOqNy5jNmkgFwkmATpHJZVXOmHNLTyc0ifKdfRdoCAtdVwcC1zQWnUESD5hVz1TJfXuuD55xwB1JzTur/AOzTi/e4c0XumpQOW pYfZ91x6Dms J9mqTmnI57Z2zTHlmm3T3RoeMoYbF8NxTK0CpSnK8ssXNOog2nQi8SAq69OWN67jTZuwzx q uPCxLllTqBzQ5plrgC0jcG4QhbOZrL16Hr0tWJpogcjXSvMpWD6Z1BhShk52ysAFW4cEuAN4uVZquS2IiIqrCIiAiIgpOPs8TT0 X VS1TdEWk9M8vbbh3K3olEUoSA4IXrxFCXmYr3MiKRm0BZQERQPHAQudpPaS6g8jUinO8/dP093JEVsUVa8EYKdPu5s1xyg7A3j3ypzqo5hEVb3Vp6a3Ylo3Wt2NaNwiJwjlpfxRnO/S/wAkompVNrDclES9QndWuGw4YIHqea3IizaCIiD/2Q==")
})
db.images.aggregate([
{
$project: {
"practiceId": "$practiceId",
"imageSize": { $binarySize: "$data" }
}
}
])
{
"practiceId" : 242,
"imageSize" : 4207.0
}
Я вставляю эти два документа:
db.images.insertMany([
{
author: "you",
data: {
"$binary": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTExMVFhUVFyAYFRcXFxsgIBggICggICAoHx8gJTAqICYxJR8fKjsrMTU3NTU1ICs7QDo1PzA1NjUBCgoKDg0OFxAQFjgdFhorNCsvKys3Ky0rNyszKzctLTMyLS03NzcrLS0rNzc3Kys4KzgrODgrKzg4NjctNy81MP/AABEIAMgAyAMBIgACEQEDEQH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sUVa8EYKdPu5s1xyg7A3j3ypzqo5hEVb3Vp6a3Ylo3Wt2NaNwiJwjlpfxRnO/S/wAkompVNrDclES9QndWuGw4YIHqea3IizaCIiD/2Q==")
}
])
Монгоэкспорт выглядит так:
{
"_id": { "$oid": "60f92b42607c82337782654e" },
"author": "you",
"data": {
"$binary": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAk...",
"$type": "00"
}
},
{
"_id": { "$oid": "60f92b42607c82337782654f" },
"author": "me",
"data": {
"$binary": {
"base64": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAA...",
"subType": "00"
}
}
}
Похоже, монго не распознает его как двоичные данные, вывод другой.
Комментарии:
1. Я думаю, что моя версия mongo старая 3.2.5, поэтому $binarySize не поддерживает
2. С новой версией он дает мне правильный вывод, но размер изображения на выходе указан в байтах. Есть ли какой-нибудь способ, которым мы можем получить его в КБ
3. Ах да, я не обратил внимания на ваше сообщение об ошибке. Это число так просто
imageSize: { $divide: [{ $binarySize: "$data" }, 1024] }
4. Спасибо за вашу помощь! но есть ли какой-нибудь способ получить размер изображения для более старой версии mongo?
5. Я так не думаю, вам нужна более свежая версия.