정의
매개변수
- $filename: 문자열
- 다운로드할 파일의 filename입니다.
- $destination: 리소스
- GridFS 파일의 콘텐츠가 기록될 쓰기 가능한 스트림입니다.
- $options: 배열
- 원하는 옵션을 지정하는 배열입니다. 이름유형설명- 수정본 - integer - 조회할 파일의 수정본입니다. 동일한 - filename를 가진 파일은- uploadDate필드로 구분됩니다.- 리비전 번호는 다음과 같이 정의됩니다: - 0 = 원래 저장된 파일 
- 1 = 첫 번째 수정본 
- 2 = 두 번째 수정본 
- 등... 
- -2 = 두 번째로 최근 수정본 
- -1 = 가장 최근의 수정본 
 - 기본값은 -1(가장 최근 수정본)입니다. 
오류/예외
MongoDB\GridFS\Exception\FileNotFoundException 선택 기준에 맞는 파일을 찾을 수 없는 경우.
MongoDB\Exception\InvalidArgumentException 매개변수 또는 옵션의 구문 분석과 관련된 오류의 경우입니다.
확장 수준의 기타 오류에 대한MongoDB\ 드라이버\Exception\RuntimeException(예: 연결 오류).
예시
$bucket = (new MongoDB\Client)->test->selectGridFSBucket(); $stream = fopen('php://temp', 'w+b'); fwrite($stream, "foobar"); rewind($stream); $bucket->uploadFromStream('filename', $stream); $destination = fopen('php://temp', 'w+b'); $bucket->downloadToStreamByName('filename', $destination); var_dump(stream_get_contents($destination, -1, 0)); 
이 경우 출력은 다음과 유사합니다:
string(6) "foobar"