@@ -284,6 +284,36 @@ inherited timeout:
284
284
:dedent:
285
285
:emphasize-lines: 3
286
286
287
+ .. _java-rs-csot-gridfs:
288
+
289
+ GridFS
290
+ ------
291
+
292
+ You can set a timeout option for :ref:`GridFS <java-rs-store-large-docs>`
293
+ operations when instantiating a ``GridFSBucket`` by using the
294
+ ``withTimeout()`` method. This timeout applies to all operations
295
+ performed on the bucket, such as uploading and downloading data. If you
296
+ do not set a timeout, the ``GridFSBucket`` instance inherits the timeout
297
+ setting from the ``MongoDatabase`` it is created with.
298
+
299
+ The following code demonstrates how to set a timeout when instantiating
300
+ a ``GridFSBucket``:
301
+
302
+ .. literalinclude:: /includes/connect/CsotExample.java
303
+ :language: java
304
+ :start-after: start-gridfsbucket-timeout
305
+ :end-before: end-gridfsbucket-timeout
306
+ :dedent:
307
+ :emphasize-lines: 3
308
+
309
+ .. important:: InputStream Timeout Support
310
+
311
+ When you call the ``uploadFromStream()`` method on a ``GridFSBucket``
312
+ that has an operation timeout, timeout breaches might occur because
313
+ the ``InputStream`` class lacks inherent read timeout support. This might
314
+ extend the operation beyond the specified timeout limit, causing a
315
+ timeout exception.
316
+
287
317
API Documentation
288
318
-----------------
289
319
@@ -298,3 +328,4 @@ API documentation:
298
328
- `ClientEncryptionSettings.Builder.timeout() <{+core-api+}/ClientEncryptionSettings.Builder.html#timeout(long,java.util.concurrent.TimeUnit)>`__
299
329
- `FindIterable.timeoutMode() <{+driver-api+}/FindPublisher.html#timeoutMode(com.mongodb.client.cursor.TimeoutMode)>`__
300
330
- `TimeoutMode <{+core-api+}/client/cursor/TimeoutMode.html>`__
331
+ - `GridFSBucket.withTimeout() <{+driver-api+}/gridfs/GridFSBucket.html#withTimeout(long,java.util.concurrent.TimeUnit)>`__
0 commit comments