@@ -609,8 +609,9 @@ def download_to_stream(self, file_id, destination):
609
609
# Get _id of file to read
610
610
file_id = fs.upload_from_stream("test_file", "data I want to store!")
611
611
# Get file to write to
612
- file = open('myfile','rwb ')
612
+ file = open('myfile','wb+ ')
613
613
fs.download_to_stream(file_id, file)
614
+ file.seek(0)
614
615
contents = file.read()
615
616
616
617
Raises :exc:`~gridfs.errors.NoFile` if no file with file_id exists.
@@ -715,12 +716,13 @@ def open_download_stream_by_name(self, filename, revision=-1):
715
716
Defaults to -1 (the most recent revision).
716
717
717
718
:Note: Revision numbers are defined as follows:
718
- 0 = the original stored file
719
- 1 = the first revision
720
- 2 = the second revision
721
- etc...
722
- -2 = the second most recent revision
723
- -1 = the most recent revision
719
+
720
+ - 0 = the original stored file
721
+ - 1 = the first revision
722
+ - 2 = the second revision
723
+ - etc...
724
+ - -2 = the second most recent revision
725
+ - -1 = the most recent revision
724
726
"""
725
727
validate_string ("filename" , filename )
726
728
@@ -764,12 +766,13 @@ def download_to_stream_by_name(self, filename, destination, revision=-1):
764
766
Defaults to -1 (the most recent revision).
765
767
766
768
:Note: Revision numbers are defined as follows:
767
- 0 = the original stored file
768
- 1 = the first revision
769
- 2 = the second revision
770
- etc...
771
- -2 = the second most recent revision
772
- -1 = the most recent revision
769
+
770
+ - 0 = the original stored file
771
+ - 1 = the first revision
772
+ - 2 = the second revision
773
+ - etc...
774
+ - -2 = the second most recent revision
775
+ - -1 = the most recent revision
773
776
"""
774
777
gout = self .open_download_stream_by_name (filename , revision )
775
778
for chunk in gout :
0 commit comments