クラス: Mongo::Grid::FSBbucket::Stream::Write
- 継承:
-
オブジェクト
- オブジェクト
- Mongo::Grid::FSBbucket::Stream::Write
- 定義:
- lib/mongo/ Grid/stream/write.rb
Overview
FS バケットにファイルを書込むストリーム。
インスタンス属性の概要を折りたたむ
-
#file_id ⇒ Object
readOnly
ファイル_id アップロードされるファイルの ID。
-
#ファイル名= string
readOnly
ファイル名 アップロードされるファイルの名前。
-
#fs ⇒ FSBucket
readOnly
Fs このストリームが書き込む fs バケット。
-
#options ⇒ Hash
readOnly
オプション 書込みストリーム オプション。
インスタンス メソッドの概要を折りたたむ
-
#abort ⇒ true
すでに挿入されているすべてのチャンクを削除して、アップロードを中止します。
-
#閉じる= BSON::ObjectId, オブジェクト
書込みストリームを閉じます。
-
#閉じました= true、false
ストリームが閉じられているかどうか。
-
#初期化(fs, オプション) = 書込み
コンストラクター
FS バケットにファイルを書き込むためのストリームを作成します。
-
書込み ( write ) (io) = ストリーム::書込み (write)
ソース ストリームまたは string から GridFS バケットに書き込みます。
-
#write_concern = Mongo::WriteConcern
アップロード時に使用される書込み保証 (write concern) を取得します。
コンストラクターの詳細
#初期化(fs, オプション) =書込み
FS バケットにファイルを書き込むためのストリームを作成します。
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 67 デフォルト 初期化(fs, ) @fs = fs @Length = 0 @n = 0 @file_id = [:file_id] || BSON::ObjectId.新着情報 @options = .dup WriteConcernオブジェクトのサポート では、@options[:write_concern].is_a?(WriteConcern::Base) の場合 ##インスタンスをキャッシュして、不必要に再構築されないようにします。 # @write_concern = @options[:write_concern] #@options[:write_concern] = @write_concern.options # end @options.freeze @filename = @options[:filename] @open = true @timeout_holder = CsonTimeoutH older.新着情報( operation_timeouts: { operation_timeout_ms: [:timeout_ms], inherited_timeout_ms: fs.database.timeout_ms } ) end |
インスタンス属性の詳細
# file_id =オブジェクト(読み取り専用)
アップロードされるファイルのIDを返します。
33 34 35 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 33 デフォルト file_id @file_id end |
#ファイル名= string (読み取り専用)
アップロードされるファイルの名前を返します。
38 39 40 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 38 デフォルト ファイル名 @filename end |
# fs → FSbucket (読み取り専用)
fs このストリームが書き込む fs バケットを返します。
28 29 30 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 28 デフォルト fs @fs end |
オプション=ハッシュ(読み取り専用)
オプション 書込みストリーム オプション。
43 44 45 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 43 デフォルト @options end |
インスタンス メソッドの詳細
#abort ⇒ true
すでに挿入されているすべてのチャンクを削除して、アップロードを中止します。
178 179 180 181 182 183 184 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 178 デフォルト 中止 fs.chunks_collection.find( { ファイル_id: file_id }, @options.merge(timeout_ms: @timeout_holder.retention_timeout_ms。) ).delete_many (@open = false) || true end |
#閉じる= BSON::ObjectId 、オブジェクト
書込みストリームを閉じます。
131 132 133 134 135 136 137 138 139 140 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 131 デフォルト 閉じる concern_open. update_Length ファイル_コレクション.insert_one( file_info, @options.merge(timeout_ms: @timeout_holder.retention_timeout_ms。) ) @open = false file_id end |
#閉じました= true 、 false
ストリームが閉じられているかどうか。
166 167 168 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 166 デフォルト 閉じましたか !@open end |
書込み ( write ) (io) =ストリーム::書込み (write)
ソース ストリームまたは string から GridFS バケットに書き込みます。
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 100 デフォルト 書込み (write)(io) concern_open. @indexes ||= ensure_indexes! @Length += 場合 io.respond_to?(:bytesize) stringオブジェクト数 io.bytesize else # IO オブジェクト io.サイズ end チャンク = ファイル::チャンク.分裂(io, file_info, @n) @n += チャンク.サイズ ただし、 チャンク.空の場合 chunks_collection.insert_many( チャンク, timeout_ms: @timeout_holder.retention_timeout_ms。 ) end 自己 end |
#write_concern = Mongo::WriteConcern
アップロード時に使用される書込み保証 (write concern) を取得します。
150 151 152 153 154 155 156 |
ファイル 'lib/mongo/Grid/stream/write.rb' 行 150 デフォルト write_concern @write_concern ||= 場合 wco = @options[:write_concern] || @options[:write] WriteConcern.得る(wco) else fs.write_concern end end |