0
이미지 렌더링 시간을 줄이고 아파치 요청을 줄이기 위해 mongodb 격자를 배치했습니다. 큰 이미지 크기에 관해 브라우저에서 어떻게 보여줄 수 있는지에 대한 설명이 필요합니까?MongoDB GridFS Clarification
사실 나는 mongodb 그리드에 저장하기 위해 하나의 이미지와 크기를 40MB 이상 가져 왔습니다. 다음 명령을 사용하여 저장됩니다. 하지만 브라우저에서 브라우저에서 40MB 이미지를 표시 할 수없고 브라우저에서 이미지를 스트리밍 할 수있는 방법은 무엇입니까?. Pls 도움이됩니다.
명령 :
1 단계 :
./mongofiles -d myfiles put /home/bharat/bin/cron/"CT0072 Madagascar Cartoon Characters .jpg"
connected to: 127.0.0.1
added file: { _id: ObjectId('512606b93f15f684e8271aee'), filename: "/home/bharat/bin/cron/CT0072 Madagascar Cartoon Characters .jpg", chunkSize: 262144, uploadDate: new Date(1361446588575), md5: "ab3e9d6a6f01f87e28f76148824a6d4b", length: 20020718 }
done!
2 단계 :
./mongofiles -d myfiles list
connected to: 127.0.0.1
/home/bharat/bin/cron/CT0072 Madagascar Cartoon Characters .jpg 20020718
3 단계 :
./mongo
MongoDB shell version: 1.8.2
> show tables;
fs.chunks
fs.files
system.indexes
> db.fs.chunks.count();
77
4 단계 : 쓰기 PHP 파일
**Program 1** - Its showing image below 10MB file. But 40MB file is not showing in Chrome Browse but Firefox showing and taking more time to display.
$mongo = new Mongo("128.181.10.28:27017");
$db = $mongo->myfiles;
$gridFS = $db->getGridFS();
$image = $gridFS->findOne("/home/bharat/bin/cron/tomas-hurricane.jpg");
$filedata = $image->getBytes();
header("Content-Length: " . strlen($filedata));
header("Content-Type: image/jpeg");
ob_clean();
echo($filedata);
**Program 2** : Tried second program but not working.
Tried 2nd Program
$mongo = new Mongo("128.181.10.28:27017");
$db = $mongo->myfiles;
$gridFS = $db->getGridFS();
$image = $gridFS->findOne("/home/bharat/bin/cron/tomas-hurricane.jpg");
header("Content-Type: image/jpeg");
$stream = $image->getResource();
while (!feof($stream)) {
echo fread($stream, 8192);
}
- Kumaran
두 번째 경우 MongoDB 서버에서 모든 바이트를 읽는데 얼마나 걸리나요? – WiredPrairie
프로그램 2 : FireFox에서 : 20 초를 찍었지 만 Chrome 브라우저에서 작동하지 않아 빈 페이지 만 표시됩니다. – Kumaran
Chrome에 파일을 로컬로로드하면 Chrome에서 파일을 표시 할 수 있습니까? (MongoDB가 아닌 경우) - 'content-length'도 보낼 수 있습니까? – WiredPrairie