@@ -179,7 +179,7 @@ def initialize(database, options = {})
179179 #
180180 # @since 2.0.0
181181 def prefix
182- @options [ :fs_name ] || @options [ :bucket_name ] || DEFAULT_ROOT
182+ @options [ :fs_name ] || @options [ :bucket_name ] || DEFAULT_ROOT
183183 end
184184
185185 # Remove a single file from the GridFS.
@@ -232,7 +232,8 @@ def delete(id)
232232 #
233233 # @since 2.1.0
234234 def open_download_stream ( id , options = nil )
235- read_stream ( id , options ) . tap do |stream |
235+ options = Utils . shallow_symbolize_keys ( options || { } )
236+ read_stream ( id , **options ) . tap do |stream |
236237 if block_given?
237238 begin
238239 yield stream
@@ -350,15 +351,15 @@ def download_to_stream_by_name(filename, io, opts = {})
350351 download_to_stream ( open_download_stream_by_name ( filename , opts ) . file_id , io )
351352 end
352353
353- # Opens an upload stream to GridFS to which the contents of a user file came be written.
354+ # Opens an upload stream to GridFS to which the contents of a file or
355+ # blob can be written.
354356 #
355- # @example Open a stream to which the contents of a file came be written.
356- # fs.open_upload_stream('a-file.txt')
357- #
358- # @param [ String ] filename The filename of the file to upload.
357+ # @param [ String ] filename The name of the file in GridFS.
359358 # @param [ Hash ] opts The options for the write stream.
360359 #
361- # @option opts [ Object ] :file_id An optional unique file id. An ObjectId is generated otherwise.
360+ # @option opts [ Object ] :file_id An optional unique file id.
361+ # A BSON::ObjectId is automatically generated if a file id is not
362+ # provided.
362363 # @option opts [ Integer ] :chunk_size Override the default chunk size.
363364 # @option opts [ Hash ] :metadata User data for the 'metadata' field of the files
364365 # collection document.
@@ -377,7 +378,8 @@ def download_to_stream_by_name(filename, io, opts = {})
377378 #
378379 # @since 2.1.0
379380 def open_upload_stream ( filename , opts = { } )
380- write_stream ( filename , opts ) . tap do |stream |
381+ opts = Utils . shallow_symbolize_keys ( opts )
382+ write_stream ( filename , **opts ) . tap do |stream |
381383 if block_given?
382384 begin
383385 yield stream
@@ -467,12 +469,12 @@ def write_concern
467469 #
468470 # @option opts [ BSON::Document ] :file_info_doc For internal
469471 # driver use only. A BSON document to use as file information.
470- def read_stream ( id , opts = nil )
471- Stream . get ( self , Stream ::READ_MODE , { file_id : id } . update ( options ) . update ( opts || { } ) )
472+ def read_stream ( id , ** opts )
473+ Stream . get ( self , Stream ::READ_MODE , { file_id : id } . update ( options ) . update ( opts ) )
472474 end
473475
474- def write_stream ( filename , opts )
475- Stream . get ( self , Stream ::WRITE_MODE , { filename : filename } . merge! ( options ) . merge! ( opts ) )
476+ def write_stream ( filename , ** opts )
477+ Stream . get ( self , Stream ::WRITE_MODE , { filename : filename } . update ( options ) . update ( opts ) )
476478 end
477479
478480 def chunks_name
0 commit comments