类com.mongodb.client.gridfs.model.GridFSDownloadOptions源码实例Demo

下面列出了怎么用com.mongodb.client.gridfs.model.GridFSDownloadOptions的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: mongo-java-driver-rx   文件: GridFSTest.java
private void doDownloadByName(final BsonDocument arguments, final BsonDocument assertion) {
    Throwable error = null;
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    try {
        GridFSDownloadOptions options = new GridFSDownloadOptions();
        if (arguments.containsKey("options")) {
            int revision = arguments.getDocument("options").getInt32("revision").getValue();
            options.revision(revision);
        }

        gridFSBucket.downloadToStream(arguments.getString("filename").getValue(), toAsyncOutputStream(outputStream),
                options).timeout(30, SECONDS).toList().toBlocking().first();
        outputStream.close();
    } catch (Throwable e) {
        error = e;
    }
    if (assertion.containsKey("result")) {
        assertNull("Should not have thrown an exception", error);
        assertEquals(DatatypeConverter.printHexBinary(outputStream.toByteArray()).toLowerCase(),
                assertion.getDocument("result").getString("$hex").getValue());
    } else if (assertion.containsKey("error")) {
        assertNotNull("Should have thrown an exception", error);
    }
}
 
源代码2 项目: mongo-java-driver-rx   文件: GridFSBucketImpl.java
@Override
public Observable<Long> downloadToStream(final String filename, final AsyncOutputStream destination,
                                        final GridFSDownloadOptions options) {
    return RxObservables.create(Observables.observe(new Block<SingleResultCallback<Long>>() {
        @Override
        public void apply(final SingleResultCallback<Long> callback) {
            wrapped.downloadToStream(filename, toCallbackAsyncOutputStream(destination), options, callback);
        }
    }), observableAdapter);
}
 
@Override
public Publisher<Long> downloadToStream(final String filename,
                                        final com.mongodb.reactivestreams.client.gridfs.AsyncOutputStream destination,
                                        final GridFSDownloadOptions options) {
    return new ObservableToPublisher<Long>(com.mongodb.async.client.Observables.observe(
            new Block<com.mongodb.async.SingleResultCallback<Long>>() {
                @Override
                public void apply(final com.mongodb.async.SingleResultCallback<Long> callback) {
                    wrapped.downloadToStream(filename, toCallbackAsyncOutputStream(destination), options, callback);
                }
            }));
}
 
@Override
public Publisher<Long> downloadToStream(final ClientSession clientSession, final String filename,
                                        final com.mongodb.reactivestreams.client.gridfs.AsyncOutputStream destination,
                                        final GridFSDownloadOptions options) {
    return new ObservableToPublisher<Long>(com.mongodb.async.client.Observables.observe(
            new Block<com.mongodb.async.SingleResultCallback<Long>>() {
                @Override
                public void apply(final com.mongodb.async.SingleResultCallback<Long> callback) {
                    wrapped.downloadToStream(clientSession.getWrapped(), filename, toCallbackAsyncOutputStream(destination), options,
                            callback);
                }
            }));
}
 
源代码5 项目: mongo-java-driver-rx   文件: GridFSBucketImpl.java
@Override
public GridFSDownloadStream openDownloadStream(final String filename, final GridFSDownloadOptions options) {
    return new GridFSDownloadStreamImpl(wrapped.openDownloadStream(filename, options), observableAdapter);
}
 
@Override
public com.mongodb.reactivestreams.client.gridfs.GridFSDownloadStream openDownloadStream(final String filename) {
    return openDownloadStream(filename, new GridFSDownloadOptions());
}
 
@Override
public com.mongodb.reactivestreams.client.gridfs.GridFSDownloadStream
openDownloadStream(final String filename, final GridFSDownloadOptions options) {
    return new GridFSDownloadStreamImpl(wrapped.openDownloadStream(filename, options));
}
 
@Override
public com.mongodb.reactivestreams.client.gridfs.GridFSDownloadStream
openDownloadStream(final ClientSession clientSession, final String filename) {
    return openDownloadStream(clientSession, filename, new GridFSDownloadOptions());
}
 
@Override
public com.mongodb.reactivestreams.client.gridfs.GridFSDownloadStream
openDownloadStream(final ClientSession clientSession, final String filename, final GridFSDownloadOptions options) {
    return new GridFSDownloadStreamImpl(wrapped.openDownloadStream(clientSession.getWrapped(), filename, options));
}
 
@Override
public Publisher<Long> downloadToStream(final String filename,
                                        final com.mongodb.reactivestreams.client.gridfs.AsyncOutputStream destination) {
    return downloadToStream(filename, destination, new GridFSDownloadOptions());
}
 
@Override
public Publisher<Long> downloadToStream(final ClientSession clientSession, final String filename,
                                        final com.mongodb.reactivestreams.client.gridfs.AsyncOutputStream destination) {
    return downloadToStream(clientSession, filename, destination, new GridFSDownloadOptions());
}
 
@Override
public GridFSDownloadPublisher downloadToPublisher(final String filename, final GridFSDownloadOptions options) {
    return executeDownloadToPublisher(openDownloadStream(filename, options));
}
 
@Override
public GridFSDownloadPublisher downloadToPublisher(final ClientSession clientSession, final String filename,
                                                 final GridFSDownloadOptions options) {
    return executeDownloadToPublisher(openDownloadStream(clientSession, filename, options));
}
 
源代码14 项目: vertx-mongo-client   文件: MongoGridFsClientImpl.java
@Override
public Future<Long> downloadByFileNameWithOptions(WriteStream<Buffer> stream, String fileName, GridFsDownloadOptions options) {
  GridFSDownloadOptions downloadOptions = new GridFSDownloadOptions();
  GridFSDownloadPublisher publisher = bucket.downloadToPublisher(fileName, downloadOptions);
  return handleDownload(publisher, stream);
}
 
源代码15 项目: mongo-java-driver-rx   文件: GridFSBucket.java
/**
 * Opens a Stream from which the application can read the contents of the stored file specified by {@code filename} and the revision
 * in {@code options}.
 *
 * @param filename the name of the file to be downloaded
 * @param options  the download options
 * @return the stream
 */
GridFSDownloadStream openDownloadStream(String filename, GridFSDownloadOptions options);
 
源代码16 项目: mongo-java-driver-rx   文件: GridFSBucket.java
/**
 * Downloads the contents of the stored file specified by {@code filename} and by the revision in {@code options} and writes the
 * contents to the {@code destination} Stream.
 *
 * @param filename    the name of the file to be downloaded
 * @param destination the destination stream
 * @param options     the download options
 * @return an observable with a single element, representing the amount of data written
 */
Observable<Long> downloadToStream(String filename, AsyncOutputStream destination, GridFSDownloadOptions options);
 
/**
 * Opens a {@code AsyncInputStream} from which the application can read the contents of the stored file specified by {@code filename}
 * and the revision in {@code options}.
 *
 * @param filename the name of the file to be downloaded
 * @param options  the download options
 * @return the stream
 * @deprecated prefer {@link GridFSBucket#downloadToPublisher(String, GridFSDownloadOptions)} instead
 */
@Deprecated
GridFSDownloadStream openDownloadStream(String filename, GridFSDownloadOptions options);
 
/**
 * Opens a {@code AsyncInputStream} from which the application can read the contents of the stored file specified by
 * {@code filename} and the revision in {@code options}.
 *
 * @param clientSession the client session with which to associate this operation
 * @param filename the name of the file to be downloaded
 * @param options  the download options
 * @return the stream
 * @mongodb.server.release 3.6
 * @since 1.7
 * @deprecated prefer {@link GridFSBucket#downloadToPublisher(ClientSession, String, GridFSDownloadOptions)} instead
 */
@Deprecated
GridFSDownloadStream openDownloadStream(ClientSession clientSession, String filename, GridFSDownloadOptions options);
 
/**
 * Downloads the contents of the stored file specified by {@code filename} and by the revision in {@code options} and writes the
 * contents to the {@code destination} Stream.
 *
 * @param filename    the name of the file to be downloaded
 * @param destination the destination stream
 * @param options     the download options
 * @return a Publisher with a single element, representing the amount of data written
 * @deprecated prefer {@link GridFSBucket#downloadToPublisher(String, GridFSDownloadOptions)} instead
 */
@Deprecated
Publisher<Long> downloadToStream(String filename, AsyncOutputStream destination, GridFSDownloadOptions options);
 
/**
 * Downloads the contents of the stored file specified by {@code filename} and by the revision in {@code options} and writes the
 * contents to the {@code destination} Stream.
 *
 * @param clientSession the client session with which to associate this operation
 * @param filename    the name of the file to be downloaded
 * @param destination the destination stream
 * @param options     the download options
 * @return a Publisher with a single element, representing the amount of data written
 * @mongodb.server.release 3.6
 * @since 1.7
 * @deprecated prefer {@link GridFSBucket#downloadToPublisher(ClientSession, String, GridFSDownloadOptions)} instead
 */
@Deprecated
Publisher<Long> downloadToStream(ClientSession clientSession, String filename, AsyncOutputStream destination,
                                 GridFSDownloadOptions options);
 
/**
 * Downloads the contents of the stored file specified by {@code filename} and by the revision in {@code options} into the
 * {@code Publisher}.
 *
 * @param filename    the name of the file to be downloaded
 * @param options     the download options
 * @return a Publisher with a single element, representing the amount of data written
 * @since 1.13
 */
GridFSDownloadPublisher downloadToPublisher(String filename, GridFSDownloadOptions options);
 
/**
 * Downloads the contents of the stored file specified by {@code filename} and by the revision in {@code options} into the
 * {@code Publisher}.
 *
 * @param clientSession the client session with which to associate this operation
 * @param filename    the name of the file to be downloaded
 * @param options     the download options
 * @return a Publisher with a single element, representing the amount of data written
 * @mongodb.server.release 3.6
 * @since 1.13
 */
GridFSDownloadPublisher downloadToPublisher(ClientSession clientSession, String filename, GridFSDownloadOptions options);
 
 类所在包
 同包方法