我已经通过上传文件成功地在 mongoDb 中创建了条目,但是有些不对劲。
上传 PDF 时,Mongo Document 的 data 属性包含大量数据,但对于 JPG 文件,它包含的数据很少:
{ "files_id" : "KYMu7tDSEerKtocCK", "n" : 0, "data" : "ÿØÿà", "_id" : "zWie2w64SEQvPQSi6" }
{ "files_id" : "KYMu7tDSEerKtocCK", "n" : 1, "data" : "_×ü", "_id" : "i2D2g7siB2NsHsw3P" }
这是 428KB jpeg 文件的两个块。而这是 308KB PDF 的条目:
{ "files_id" : "fPMCentq3zdqmt3K9", "n" : 0, "data" : "%PDF-1.3\r%âãÏÓ\n1 0 obj\n<< \n/Creator (Canon )\n/CreationDate (D:20090321174932+01'00')\n/Producer ( )\n>> \nendobj\n2 0 obj\n<< /Type /XObject /Subtype /Image /Width 620 /Height 877 \n/BitsPerComponent 8 /ColorSpace /DeviceRGB\n/Filter /DCTDecode /Length 28744 >> \nstream\nÿØÿà", "_id" : "n9qiR2boCYGfzaLYn" }
{ "files_id" : "fPMCentq3zdqmt3K9", "n" : 1, "data" : "> Tj\n1 0 0 1 68.64 318.72 Tm\n<646520> Tj\n1 0 0 1 83.04 319.68 Tm\n<706572736F6E6E657320> Tj\n1 0 0 1 132.00 317.28 Tm\n<656E20> Tj\n1 0 0 1 145.92 316.80 Tm\n<6D656E61676520> Tj\n1 0 0 1 184.80 316.32 Tm\n<64616E7320> Tj\n1 0 0 1 208.32 316.80 Tm\n<726C74756620> Tj\n1 0 0 1 231.84 315.84 Tm\n<726F67656D656E7420> Tj\n1 0 0 1 297.12 314.88 Tm\n<4E62726520> Tj\n1 0 0 1 321.60 313.92 Tm\n<646520> Tj\n1 0 0 1 335.52 315.36 Tm\n<70657273276E6E654520> Tj\n1 0 0 1 384.96 312.96 Tm\n<656E20> Tj\n1 0 0 1 398.88 312.96 Tm\n<6D2E6E61676520> Tj\n1 0 0 1 437.76 312.00 Tm\n<64616E7320> Tj\n1 0 0 1 461.76 312.00 Tm\n<6675747572726F67656D656E74> Tj\n0.48 Tc\n/F3 12.0 Tf\n1 0 0 1 44.64 281.28 Tm\n<4E62726520> Tj\n1 0 0 1 69.12 281.28 Tm\n<646520> Tj\n1 0 0 1 83.52 282.24 Tm\n<70696563657320> Tj\n1 0 0 1 114.24 280.32 Tm\n<61637475656C6C6545> Tj\n0.48 Tc\n1 0 0 1 44.16 263.52 Tm\n<473672456E636520> Tj\n1 0 0 1 86.40 262.56 Tm\n<45636C75656C6C65> Tj\n0.48 Tc\n1 0 0 1 44.64 244.80 Tm\n<4C6779657220> Tj\n1 0 0 1 72.96 244.32 Tm\n<61637475656C5F> Tj\n0.48 Tc\n1 0 0 1 44.16 214.08 Tm\n<456E66616E74287329> Tj\n0.48 Tc\n1 0 0 1 44.64 195.84 Tm\n<5072646E6F6D20> Tj\n1 0 0 1 83.04 195.36 Tm\n<657420> Tj\n1 0 0 1 94.08 194.88 Tm\n<6461746520> Tj\n1 0 0 1 115.68 194.40 Tm\n<646520> Tj\n1 0 0 1 129.60 194.40 Tm\n<6E61697365656E6365> Tj\n0.48 Tc\n/F3 13.0 Tf\n1 0 0 1 297.60 351.84 Tm\n<4E2720> Tj\n1 0 0 1 311.04 351.84 Tm\n<646520> Tj\n1 0 0 1 324.96 351.36 Tm\n<74656C2E20> Tj\n1 0 0 1 341.76 353.28 Tm\n<7072697641> Tj\n0.48 Tc\n/F3 12.0 Tf\n1 0 0 1 297.12 333.60 Tm\n<4E2720> Tj\n1 0 0 1 311.04 333.12 Tm\n<646520> Tj\n1 0 0 1 324.96 333.12 Tm\n<74366C2E20> Tj\n1 0 0 1 341.28 333.60 Tm\n<70726F6620> Tj\n1 0 0 1 361.44 330.24 Tm\n<5F> Tj\n0.48 Tc\n1 0 0 1 297.12 277.44 Tm\n<4E62726520> Tj\n1 0 0 1 321.12 276.96 Tm\n<648020> Tj\n1 0 0 1 335.52 278.40 Tm\n<70696263807320> Tj\n1 0 0 1 367.20 276.48 Tm\n<616F7475656C6C65732D5F5F3A> Tj\n0.48 Tc\n/F3 13.0 Tf\n1 0 0 1 296.64 259.68 Tm\n<476472616E636520> Tj\n1 0 0 1 337.92 258.72 Tm\n<61637475656C74652D20> Tj\n1 0 0 1 452.64 254.88 Tm\n<5F> Tj\n0.48 Tc\n/F3 11.0 Tf\n1 0 0 1 297.12 241.44 Tm\n<4C6F79656620> Tj\n1 0 0 1 324.96 240.48 Tm\n<42637475656C20> Tj\n1 0 0 1 355.68 238.56 Tm\n<5F> Tj\n0.48 Tc\n/F3 12.0 Tf\n1 0 0 1 297.12 209.76 Tm\n<456E66616874287329> Tj\n0.48 Tc\n1 0 0 1 297.12 192.00 Tm\n<5072366E6F6D20> Tj\n1 0 0 1 334.56 191.52 Tm\n<657420> Tj\n1 0 0 1 346.08 191.52 Tm\n<64656C462E2E6320> Tj\n1 0 0 1 382.08 190.56 Tm\n<6E61697373616E6365> Tj\n0.48 Tc\n1 0 0 1 44.16 128.16 Tm\n<41757472657320> Tj\n1 0 0 1 79.68 128.64 Tm\n<706572736F6E6E656120> Tj\n1 0 0 1 131.52 127.20 Tm\n<766976456E6C20> Tj\n1 0 0 1 163.68 126.72 Tm\n<64616E7320> Tj\n1 0 0 1 189.60 126.24 Tm\n<6C6520> Tj\n1 0 0 1 201.12 125.76 Tm\n<6D366E61676520> Tj\n1 0 0 1 248.64 125.76 Tm\n<4574616C20> Tj\n1 0 0 1 269.28 125.28 Tm\n<636976696C> Tj\n0.48 Tc\n1 0 0 1 378.72 122.88 Tm\n<4461746520> Tj\n1 0 0 1 401.76 122.40 Tm\n<646520> Tj\n1 0 0 1 416.16 122.40 Tm\n<6E61693673616E636F> Tj\n0.48 Tc\n1 0 0 1 378.24 105.12 Tm\n<526576656E7520> Tj\n1 0 0 1 414.72 104.16 Tm\n<62727574> Tj\n0.48 Tc\n1 0 0 1 44.16 78.72 Tm\n<416E696D61757820> Tj\n1 0 0 1 89.76 78.24 Tm\n<766979616E6920> Tj\n1 0 0 1 120.96 77.76 Tm\n<64616E7320> Tj\n1 0 0 1 147.36 77.28 Tm\n<6C6520> Tj\n1 0 0 1 158.40 76.80 Tm\n<6D456E73676520> Tj\n1 0 0 1 216.00 76.32 Tm\n<47656E7265> Tj\n0.00 Tc\n/F3 13.0 Tf\n1 0 0 1 249.12 107.04 Tm\n<456D706C6F79657572> Tj\n0.00 Tc\n1 0 0 1 378.24 73.92 Tm\n<4E6F6D627265> Tj\nET\n\nendstream\nendobj\n94 0 obj\n<< /Length 27 >> \nstream\n% CANON_PFINF_TYPE2_TEXTON\n\nendstream\nendobj\n95 0 obj\n<< /Length 2831 >> \nstream\nq\n595.20 0 0 841.92 0.00 0.00 cm\n/Obj51 Do\nQ\nq\n0.173 0.090 0.184 rg\n441.60 0 0 756.48 19.20 73.92 cm\n/Obj52 Do\nQ\nq\n0.137 0.059 0.149 rg\n303.36 0 0 19.20 203.52 772.80 cm\n/Obj53 Do\nQ\nq\n0.494 0.329 0.576 rg\n303.36 0 0 19.20 203.52 772.80 cm\n/Obj54 Do\nQ\nq\n0.416 0.400 0.620 rg\n253.44 0 0 104.64 326.40 680.64 cm\n/Obj55 Do\nQ\nq\n0.137 0.059 0.149 rg\n226.56 0 0 57.60 172.80 650.88 cm\n/Obj56 Do\nQ\nq\n0.282 0.239 0.506 rg\n226.56 0 0 57.60 172.80 650.88 cm\n/Obj57 Do\nQ\nq\n0.169 0.090 0.180 rg\n84.48 0 0 27.84 42.24 503.04 cm\n/Obj58 Do\nQ\nq\n0.161 0.063 0.282 rg\n84.48 0 0 27.84 42.24 503.04 cm\n/Obj59 Do\nQ\nq\n0.188 0.110 0.200 rg\n230.40 0 0 17.28 295.68 491.52 cm\n/Obj60 Do\nQ\nq\n0.298 0.078 0.282 rg\n230.40 0 0 17.28 295.68 491.52 cm\n/Obj61 Do\nQ\nq\n0.522 0.569 0.678 rg\n230.40 0 0 17.28 295.68 491.52 cm\n/Obj62 Do\nQ\nq\n0.180 0.102 0.192 rg\n149.76 0 0 14.40 295.68 476.16 cm\n/Obj63 Do\nQ\nq\n0.463 0.467 0.714 rg\n149.76 0 0 14.40 295.68 476.16 cm\n/Obj64 Do\nQ\nq\n0.165 0.086 0.176 rg\n80.64 0 0 12.48 42.24 463.68 cm\n/Obj65 Do\nQ\nq\n0.114 0.082 0.278 rg\n80.64 0 0 12.48 42.24 463.68 cm\n/Obj66 Do\nQ\nq\n0.173 0.094 0.184 rg\n84.48 0 0 11.52 42.24 371.52 cm\n/Obj67 Do\nQ\nq\n0.153 0.129 0.263 rg\n84.48 0 0 11.52 42.24 371.52 cm\n/Obj68 Do\nQ\nq\n0.227 0.149 0.239 rg\n165.12 0 0 31.68 42.24 333.12 cm\n/Obj69 Do\nQ\nq\n0.220 0.102 0.455 rg\n165.12 0 0 31.68 42.24 333.12 cm\n/Obj70 Do\nQ\nq\n0.180 0.102 0.192 rg\n76.80 0 0 48.00 295.68 406.08 cm\n/Obj71 Do\nQ\nq\n0.027 0.063 0.239 rg\n76.80 0 0 48.00 295.68 406.08 cm\n/Obj72 Do\nQ\nq\n0.184 0.106 0.196 rg\n84.48 0 0 11.52 295.68 367.68 cm\n/Obj73 Do\nQ\nq\n0.129 0.098 0.294 rg\n84.48 0 0 11.52 295.68 367.68 cm\n/Obj74 Do\nQ\nq\n0.067 0.035 0.231 rg\n330.24 0 0 11.52 195.84 394.56 cm\n/Obj75 Do\nQ\nq\n0.369 0.149 0.353 rg\n122.88 0 0 7.68 145.92 387.84 cm\n/Obj76 Do\nQ\nq\n0.122 0.090 0.286 rg\n122.88 0 0 7.68 145.92 387.84 cm\n/Obj77 Do\nQ\nq\n0.506 0.302 0.812 rg\n122.88 0 0 7.68 145.92 387.84 cm\n/Obj78 Do\nQ\nq\n0.188 0.110 0.200 rg\n483.84 0 0 18.24 42.24 309.12 cm\n/Obj79 Do\nQ\nq\n0.110 0.078 0.275 rg\n483.84 0 0 18.24 42.24 309.12 cm\n/Obj80 Do\nQ\nq\n0.176 0.098 0.188 rg\n111.36 0 0 48.00 42.24 242.88 cm\n/Obj81 Do\nQ\nq\n0.275 0.125 0.278 rg\n111.36 0 0 48.00 42.24 242.88 cm\n/Obj82 Do\nQ\nq\n0.161 0.082 0.173 rg\n134.40 0 0 27.84 42.24 194.88 cm\n/Obj83 Do\nQ\nq\n0.200 0.102 0.322 rg\n134.40 0 0 27.84 42.24 194.88 cm\n/Obj84 Do\nQ\nq\n0.184 0.106 0.196 rg\n230.40 0 0 15.36 295.68 345.60 cm\n/Obj85 Do\nQ\nq\n0.510 0.612 0.765 rg\n230.40 0 0 15.36 295.68 345.60 cm\n/Obj86 Do\nQ\nq\n0.196 g\n92.16 0 0 12.48 295.68 330.24 cm\n/Obj87 Do\nQ\nq\n0.180 0.102 0.192 rg\n92.16 0 0 12.48 295.68 330.24 cm\n/Obj88 Do\nQ\nq\n0.490 0.525 0.702 rg\n92.16 0 0 12.48 295.68 330.24 cm\n/Obj89 Do\nQ\nq\n0.165 0.086 0.176 rg\n153.60 0 0 11.52 295.68 239.04 cm\n/Obj90 Do\nQ\nq\n0.357 0.114 0.075 rg\n153.60 0 0 11.52 295.68 239.04 cm\n/Obj91 Do\nQ\nq\n0.188 0.090 0.310 rg\n153.60 0 0 11.52 295.68 239.04 cm\n/Obj92 Do\nQ\n\nendstream\nendobj\n96 0 obj\n<< \n/Type /Page \n/MediaBox [ 0 0 595.20 841.92 ] \n/Parent 12 0 R \n/Resources << /Font << /F3 8 0 R >> /XObject << /Obj51 51 0 R /Obj52 52 0 R /Obj53 53 0 R /Obj54 54 0 R /Obj55 55 0 R /Obj56 56 0 R /Obj57 57 0 R /Obj58 58 0 R /Obj59 59 0 R /Obj60 60 0 R /Obj61 61 0 R /Obj62 62 0 R /Obj63 63 0 R /Obj64 64 0 R /Obj65 65 0 R /Obj66 66 0 R /Obj67 67 0 R /Obj68 68 0 R /Obj69 69 0 R /Obj70 70 0 R /Obj71 71 0 R /Obj72 72 0 R /Obj73 73 0 R /Obj74 74 0 R /Obj75 75 0 R /Obj76 76 0 R /Obj77 77 0 R /Obj78 78 0 R /Obj79 79 0 R /Obj80 80 0 R /Obj81 81 0 R /Obj82 82 0 R /Obj83 83 0 R /Obj84 84 0 R /Obj85 85 0 R /Obj86 86 0 R /Obj87 87 0 R /Obj88 88 0 R /Obj89 89 0 R /Obj90 90 0 R /Obj91 91 0 R /Obj92 92 0 R >> /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] >> \n/Contents [ 94 0 R 95 0 R 93 0 R ] \n>> \nendobj\n97 0 obj\n<< /Type /XObject /Subtype /Image /Width 620 /Height 877 \n/BitsPerComponent 8 /ColorSpace /DeviceRGB\n/Filter /DCTDecode /Length 23332 >> \nstream\nÿØÿà", "_id" : "Xc5vW38g9E53Tptqy" }
很明显,PDF 中的字符串数据被存储,而 jpeg 中的二进制数据丢失了。
这是上传文件的代码(所有上传的按钮相同):
Template.loadImages.events({
"change .file-upload-input": function (event, template) {
var func = this;
var files = event.currentTarget.files;
_.each(files, function (file, idx) {
ImageFiles.storeFile(file);
});
}
})
谢谢您的支持。