클래스: Mongo::Grid::FSBucket::Stream::Write
- 상속:
-
객체
- 객체
- Mongo::Grid::FSBucket::Stream::Write
- 다음에 정의됨:
- lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb
개요
FSBucket에 파일을 쓰는 스트림 입니다.
인스턴스 속성 요약 접기
-
#file_id ⇒ 객체
읽기 전용
File_id 업로드 중인 파일 의 ID입니다.
-
#파일 이름 ⇒ string
읽기 전용
파일 이름 업로드 중인 파일의 이름입니다.
-
#fs ⇒ FSBucket
읽기 전용
Fs 이 스트림이 기록하는 fs 버킷입니다.
-
옵션 #개 ⇒ 해시
읽기 전용
옵션 쓰기 (write) 스트림 옵션입니다.
인스턴스 메서드 요약 접기
-
#중단 ⇒ true
이미 삽입된 모든 청크를 삭제하여 업로드를 중단합니다.
-
#닫기 ⇒ BSON::ObjectId, Object
쓰기 스트림을 닫습니다.
-
#닫았나요? ⇒ 참, 거짓
스트림이 닫혀 있나요?
-
#initialize(fs, options) ⇒ 쓰기
생성자
FSBucket에 파일을 쓰기 위한 스트림을 만듭니다.
-
#write(io) ⇒ Stream::Write
소스 스트림 또는 string 에서 GridFS 버킷에 씁니다.
-
#write_concern ⇒ Mongo::WriteConcern
업로드 시 사용되는 쓰기 고려 (write concern) 를 가져옵니다.
생성자 세부 정보
#initialize(fs, options) ⇒ 쓰기
FSBucket에 파일을 쓰기 위한 스트림을 만듭니다.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 70 def 초기화(fs, ) @fs = fs @Length = 0 @n = 0 @file_id = [:file_id] || BSON::ObjectId.신규 @options = .dup =begin WriteConcern 객체 지원 if @options[:write_concern].is_a?(WriteConcern::Base) # 인스턴스를 캐시하여 불필요하게 재구성하지 않도록 합니다. @write_concern = @options[:write_concern] @options[:write_concern] = @write_concern.options end =end @options.동결 @filename = @options[:filename] @open = true @timeout_holder = CsotTimeoutHolder.신규( operation_timeout: { operation_timeout_ms: [:timeout_ms], inherited_timeout_ms: fs.database.timeout_ms } ) end |
인스턴스 속성 세부 정보
#file_id ⇒ 객체 (읽기 전용)
반환값 file_id 업로드 중인 파일의 ID입니다.
36 37 38 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 36 def file_id @file_id end |
#파일 이름 ⇒ string (읽기 전용)
파일 이름을 반환합니다. 업로드 중인 파일 의 이름입니다.
41 42 43 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 41 def 파일 이름 @filename end |
#fs ⇒ FSBucket (읽기 전용)
반환값 fs 이 스트림 이 기록하는 fs 버킷입니다.
31 32 33 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 31 def fs @fs end |
#options ⇒ 해시 (읽기 전용)
반환값 옵션 쓰기 스트림 옵션입니다.
46 47 48 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 46 def @options end |
인스턴스 메서드 세부 정보
#중단 ⇒ true
이미 삽입된 모든 청크를 삭제하여 업로드를 중단합니다.
182 183 184 185 186 187 188 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 182 def 중단 fs.chunks_collection.찾기( { :files_id => file_id }, @options.merge(timeout_ms: @timeout_holder.잔여 시간 초과_ms!) ).delete_many (@open = 거짓) || true end |
#닫기 ⇒ BSON::ObjectId, 객체
쓰기 스트림을 닫습니다.
135 136 137 138 139 140 141 142 143 144 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 135 def 닫기 sure_open! update_Length 파일 컬렉션.insert_one( file_info, @options.merge(timeout_ms: @timeout_holder.잔여 시간 초과_ms!) ) @open = 거짓 file_id end |
#닫았나요? ⇒ true, false
스트림이 닫혀 있나요?
170 171 172 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 170 def 닫힘? !@open end |
#write(io) ⇒ Stream::Write
소스 스트림 또는 string 에서 GridFS 버킷에 씁니다.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 104 def 쓰기(io) sure_open! @indexes ||= ensure_indexes! @Length += 만약 io.response_to?(:bytesize) # string 객체 io.bytesize other # IO 객체 io.size end 청크 = file::청크.split(io, file_info, @n) @n += 청크.size 하지 않는 한 청크.비어 있나요? chunks_collection.insert_many( 청크, timeout_ms: @timeout_holder.잔여 시간 초과_ms! ) end self end |
#write_concern ⇒ Mongo::WriteConcern
업로드 시 사용되는 쓰기 고려 (write concern) 를 가져옵니다.
154 155 156 157 158 159 160 |
# 파일 'lib/ Mongo/grid/ 스트림/ 쓰기 (write).rb', 줄 154 def write_concern @write_concern ||= 만약 wco = @options[:write_concern] || @options[:write] writeConcern.get(wco) other fs.write_concern end end |