public GridFsResource getResource(GridFSFile file) { Assert.notNull(file, "GridFSFile must not be null!"); return new GridFsResource(file, getGridFs().openDownloadStream(file.getObjectId())); }
public GridFsResource getResource(GridFSFile file) { Assert.notNull(file, "GridFSFile must not be null!"); return new GridFsResource(file, getGridFs().openDownloadStream(file.getObjectId())); }
@Override public InputStream getStream() { return gridFSBucket.openDownloadStream(digest); } }
public InputStream open() { ds = getBucket().openDownloadStream(mongoFileId); GridFSFile file = ds.getGridFSFile(); mongoFileId = file.getObjectId(); // setMetadataDoc(file.getMetadata()); return ds; }
public Long size() { if (ds == null) { ds = getBucket().openDownloadStream(mongoFileId); } return ds.getGridFSFile().getLength(); }
private void loadContentFromBinaryStorageToField(String bucketName, Document currentDocument, String fieldName) { GridFSBucket gridFSFilesBucket = getGridFSFilesBucket( mongoDatabase, bucketName ); Object uploadId = currentDocument.get( fieldName ); if ( uploadId != null ) { GridFSDownloadStream gridFSDownloadStream = gridFSFilesBucket.openDownloadStream( (ObjectId) uploadId ); GridFS value = new GridFS( gridFSDownloadStream ); currentDocument.put( fieldName, value ); } }
@Override public PayloadStream getBlobStream(BucketPath bucketPath, StorageMetadata storageMetadata) { LOGGER.debug("start getBlobStream for " + bucketPath); if (storageMetadata == null) { storageMetadata = getStorageMetadata(bucketPath); } GridFSBucket bucket = getGridFSBucket(bucketPath); checkBucketExists(bucket); String filename = bucketPath.getObjectHandle().getName(); GridFSDownloadOptions options = new GridFSDownloadOptions(); GridFSDownloadStream fileStream = bucket.openDownloadStream(filename, options); PayloadStream payloadStream = new SimplePayloadStreamImpl(storageMetadata, fileStream); LOGGER.debug("finished getBlobStream for " + bucketPath); return payloadStream; }
private void loadContentFromBinaryStorageToField(String bucketName, Document currentDocument, String fieldName) { GridFSBucket gridFSFilesBucket = getGridFSFilesBucket( mongoDatabase, bucketName ); Object uploadId = currentDocument.get( fieldName ); if ( uploadId != null ) { GridFSDownloadStream gridFSDownloadStream = gridFSFilesBucket.openDownloadStream( (ObjectId) uploadId ); GridFS value = new GridFS( gridFSDownloadStream ); currentDocument.put( fieldName, value ); } }
@Override public InputStream getAssociatedDocumentStream(String uniqueId, String fileName) { GridFSBucket gridFS = createGridFSConnection(); GridFSFile file = gridFS.find(new Document(ASSOCIATED_METADATA + "." + FILE_UNIQUE_ID_KEY, getGridFsId(uniqueId, fileName))).first(); if (file == null) { return null; } InputStream is = gridFS.openDownloadStream(file.getObjectId()); ; Document metadata = file.getMetadata(); if (metadata.containsKey(COMPRESSED_FLAG)) { boolean compressed = (boolean) metadata.remove(COMPRESSED_FLAG); if (compressed) { is = new InflaterInputStream(is); } } return is; }
InputStream inputStream = getGridFs().openDownloadStream(file.getId()); Document metadata = file.getMetadata();