Skip to content

Commit 3a2790f

Browse files
committed
DOCS-13934, DOCS-13935 mongofiles get put support multiple and regex
1 parent 2e85dc3 commit 3a2790f

File tree

1 file changed

+55
-17
lines changed

1 file changed

+55
-17
lines changed

source/mongofiles.txt

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -519,26 +519,36 @@ Commands
519519
Lists the files in the GridFS store with names that match any
520520
portion of ``<string>``.
521521

522-
.. describe:: put <filename>
522+
.. describe:: put <filename1[ filename2] ...>
523523

524-
Copy the specified file from the local file system into GridFS
525-
storage.
524+
Copy the specified file or files from the local file system into
525+
GridFS storage. Multiple files can be specified as a space-separated
526+
list.
526527

527-
Here, ``<filename>`` refers to the name the object will have in
528-
GridFS, and :binary:`~bin.mongofiles` assumes that this reflects the name the
529-
file has on the local file system. If the local filename is
530-
different use the :option:`mongofiles --local` option.
528+
Each specified filename refers to the name the object will have in
529+
GridFS, and :binary:`~bin.mongofiles` assumes that this reflects the
530+
name the file has on the local file system. If the local filename is
531+
different, use the :option:`mongofiles --local` option.
531532

532-
.. describe:: get <filename>
533+
.. describe:: get <filename1[ filename2] ...>
533534

534-
Copy the specified file from GridFS storage to the local file
535-
system.
535+
Copy the specified file or files from GridFS storage to the local
536+
file system.
536537

537-
Here, ``<filename>`` refers to the name the object will have in
538-
GridFS. :binary:`~bin.mongofiles` writes the file to the local
539-
file system using the file's ``filename`` in GridFS. To choose a
540-
different location for the file on the local file system, use the
541-
:option:`--local <mongofiles --local>` option.
538+
Each specified filename refers to the name the object has in
539+
GridFS, and :binary:`~bin.mongofiles` will use this filename when
540+
writing to the local file system.
541+
542+
If specifying *only one* ``filename`` to the ``get`` command, you can
543+
use the :option:`--local <mongofiles --local>` option to specify a
544+
different local filename to write to, if desired. The
545+
:option:`--local <mongofiles --local>` option **cannot** be used if
546+
specifying *more than one* ``filename`` to the ``get`` command.
547+
548+
.. note:
549+
550+
To copy files from GridFS storage that match a regular expression,
551+
use the ``get_regex`` command instead.
542552

543553
.. describe:: get_id "<_id>"
544554

@@ -548,10 +558,29 @@ Commands
548558
non-ObjectId values for ``<_id>``.
549559

550560
:binary:`~bin.mongofiles` writes the file to the local
551-
file system using the file's ``filename`` in GridFS. To choose a
561+
file system using the file's filename in GridFS. To choose a
552562
different location for the file on the local file system, use the
553563
:option:`--local <mongofiles --local>` option.
554564

565+
.. describe:: get_regex <regex> --regexOptions <regex-options>
566+
567+
Copy the file or files, matched by the specified ``<regex>``
568+
expression, from GridFS storage to the local file system. The
569+
``get_regex`` command uses Perl compatible regular expressions
570+
("PCRE") version 8.42 with UTF-8 support.
571+
572+
You may optionally specify one or more ``<regex-options>`` using the
573+
``--regexOptions`` flag. These can be any of the
574+
:ref:`options supported by the $regex operator
575+
<regex-query-options>`, which include settings such as
576+
case-insensitivity. Multiple options should be provided together
577+
without separators, e.g. ``--regexOptions si``
578+
579+
:binary:`~bin.mongofiles` writes the file or files to the local
580+
file system using each file's matched filename in GridFS. You
581+
**cannot** use the :option:`--local <mongofiles --local>` option with
582+
the ``get_regex`` command.
583+
555584
.. describe:: delete <filename>
556585

557586
Delete the specified file from GridFS storage.
@@ -611,7 +640,8 @@ following command:
611640
mongofiles -d=records search corinth
612641

613642
To list all files in the GridFS collection in the ``records`` database
614-
that begin with the string ``32``, you can use the following command:
643+
with names that begin with the string ``32``, you can use the following
644+
command:
615645

616646
.. code-block:: sh
617647

@@ -624,6 +654,14 @@ database named ``32-corinth.lp``, you can use the following command:
624654

625655
mongofiles -d=records get 32-corinth.lp
626656

657+
To fetch all files from the GridFS collection in the ``records``
658+
database with names beginning with the string ``32`` and ending with the
659+
string ``.lp``, you can use the following command:
660+
661+
.. code-block:: sh
662+
663+
mongofiles -d=records get_regex 32*.lp
664+
627665
To fetch the file from the GridFS collection in the ``records`` database
628666
with ``_id: ObjectId("56feac751f417d0357e7140f")``, you can use the
629667
following command:

0 commit comments

Comments
 (0)