@Override public long contentLength() throws IOException { verifyExists(); return file.getLength(); }
@Override public long contentLength() throws IOException { verifyExists(); return file.getLength(); }
GridFSDownloadStreamImpl(@Nullable final ClientSession clientSession, final GridFSFile fileInfo, final MongoCollection<Document> chunksCollection) { this.clientSession = clientSession; this.fileInfo = notNull("file information", fileInfo); this.chunksCollection = notNull("chunks collection", chunksCollection); fileId = fileInfo.getId(); length = fileInfo.getLength(); chunkSizeInBytes = fileInfo.getChunkSize(); numberOfChunks = (int) Math.ceil((double) length / chunkSizeInBytes); }
@Override public long contentLength() throws IOException { verifyExists(); return file.getLength(); }
@Override @SuppressWarnings("deprecation") public void encode(final BsonWriter writer, final GridFSFile value, final EncoderContext encoderContext) { BsonDocument bsonDocument = new BsonDocument(); bsonDocument.put("_id", value.getId()); bsonDocument.put("filename", new BsonString(value.getFilename())); bsonDocument.put("length", new BsonInt64(value.getLength())); bsonDocument.put("chunkSize", new BsonInt32(value.getChunkSize())); bsonDocument.put("uploadDate", new BsonDateTime(value.getUploadDate().getTime())); if (value.getMD5() != null) { bsonDocument.put("md5", new BsonString(value.getMD5())); } Document metadata = value.getMetadata(); if (metadata != null) { bsonDocument.put("metadata", new BsonDocumentWrapper<Document>(metadata, documentCodec)); } Document extraElements = value.getExtraElements(); if (extraElements != null) { bsonDocument.putAll(new BsonDocumentWrapper<Document>(extraElements, documentCodec)); } bsonDocumentCodec.encode(writer, bsonDocument, encoderContext); }
public Long size() { if (ds == null) { ds = getBucket().openDownloadStream(mongoFileId); } return ds.getGridFSFile().getLength(); }
GridFSDownloadStreamImpl(@Nullable final ClientSession clientSession, final GridFSFile fileInfo, final MongoCollection<Document> chunksCollection) { this.clientSession = clientSession; this.fileInfo = notNull("file information", fileInfo); this.chunksCollection = notNull("chunks collection", chunksCollection); fileId = fileInfo.getId(); length = fileInfo.getLength(); chunkSizeInBytes = fileInfo.getChunkSize(); numberOfChunks = (int) Math.ceil((double) length / chunkSizeInBytes); }
public long contentLength() throws IOException { GridFSFile file = gridfs.findOne(query(whereFilename().is(location))); if (file == null) { return 0L; } return file.getLength(); }
@Override public void getOne(String path, Handler<AsyncResult<ChunkReadStream>> handler) { GridFSDownloadStream downloadStream = getGridFS().openDownloadStream(PathUtils.normalize(path)); downloadStream.getGridFSFile((file, t) -> context.runOnContext(v -> { if (t != null) { handler.handle(Future.failedFuture(t)); } else { long length = file.getLength(); int chunkSize = file.getChunkSize(); handler.handle(Future.succeededFuture(new MongoDBChunkReadStream( downloadStream, length, chunkSize, context))); } })); }
GridFSDownloadStreamImpl(@Nullable final ClientSession clientSession, final GridFSFile fileInfo, final MongoCollection<Document> chunksCollection) { this.clientSession = clientSession; this.fileInfo = notNull("file information", fileInfo); this.chunksCollection = notNull("chunks collection", chunksCollection); fileId = fileInfo.getId(); length = fileInfo.getLength(); chunkSizeInBytes = fileInfo.getChunkSize(); numberOfChunks = (int) Math.ceil((double) length / chunkSizeInBytes); }
@Override public void stop(boolean delete) { gridFSBucket.find(Filters.exists(String.format("%s.%s", METADATA_PROPERTY_METADATA, msKey), false)) // .forEach((Block<GridFSFile>) file -> { status.numBinariesGC += 1; status.sizeBinariesGC += file.getLength(); if (delete) { gridFSBucket.delete(file.getId()); } }); startTime = 0; } }
@Override @SuppressWarnings("deprecation") public void encode(final BsonWriter writer, final GridFSFile value, final EncoderContext encoderContext) { BsonDocument bsonDocument = new BsonDocument(); bsonDocument.put("_id", value.getId()); bsonDocument.put("filename", new BsonString(value.getFilename())); bsonDocument.put("length", new BsonInt64(value.getLength())); bsonDocument.put("chunkSize", new BsonInt32(value.getChunkSize())); bsonDocument.put("uploadDate", new BsonDateTime(value.getUploadDate().getTime())); if (value.getMD5() != null) { bsonDocument.put("md5", new BsonString(value.getMD5())); } Document metadata = value.getMetadata(); if (metadata != null) { bsonDocument.put("metadata", new BsonDocumentWrapper<Document>(metadata, documentCodec)); } Document extraElements = value.getExtraElements(); if (extraElements != null) { bsonDocument.putAll(new BsonDocumentWrapper<Document>(extraElements, documentCodec)); } bsonDocumentCodec.encode(writer, bsonDocument, encoderContext); }