Try Studio 3T for Free

GridFS Support

All three Studio 3T editions support GridFS, the method MongoDB uses to store files larger than the document size limit of 16 MB. Try it today.

MongoDB and GridFS

GridFS is the file abstraction method MongoDB uses to store and retrieve files larger than 16 MB.

GridFS divides large files into equal chunks with a default size of 255 kB and stores them as a separate document. The last chunk, however, can be as large as necessary.

MongoDB creates two collections to store the files. The first collection – chunks – contains the file chunks; the second – files – contains the file metadata. When you search GridDS for a file, the driver will reassemble the chunks as needed.

GridFS is a fitting mechanism to store files in MongoDB, which complements the schema-less (hence faster) retrieval of information provided by the document model.

Because files are divided into smaller chunks, it’s easier to access specific sections of a file, sparing the memory-expensive task of loading an entire file.

GridFS Support in Studio 3T

In Studio 3T, each database has a corresponding GridFS Buckets folder.

Within this folder is a default bucket called Images, but you can add more buckets as needed.

Add a new GridFS bucket

Add GridFS bucket in Studio 3T

  1. Right-click on the GridFS Buckets folder.
  2. Choose Add Bucket.
  3. Name your bucket.
  4. Click OK.

Drop a GridFS bucket

  1. Right-click on the bucket to be deleted.
  2. Choose Drop Bucket.

Open GridFS view

  • Right-click – Right-click on the target GridFS bucket and choose Open GridFS view.One way to add a file is to right click anywhere in GridFS view
  • Hotkey – Choose the bucket to view and press EnterOpen GridFS view

Add a new file

  • Right-click – Right-click anywhere within the GridFS view and choose Add Files.One way to add a file is to right click anywhere in GridFS view
  • Button – Click on the green + sign in the toolbar.Click on the green + sign to add a file

Delete a file

  • Right-click – Right-click on the file to be deleted and choose Remove file(s).
    Open GridFS view
  • Button – Click on the red – sign in the toolbar.Delete a file by clicking on the - sign
  • Hotkey – ⌫ (fn + ⌫  on Mac)

Save a file

  • Right-click – Right-click on the file you want to save and choose Save to Disk.Save GridFS file to disk by right-clicking on a file and choosing Save to Disk
  • Button – Click on the disk icon in the toolbar.Click on the disk icon in the toolbar to save the GridFS file
  • Hotkey – Ctrl + S (⌘ + S)

View a file

  • Right-click – Right-click on the file you want to view and choose View File.
    View GridFS file by right-clicking on the file
  • Button – Choose the file you want to view and click on the lens icon in the toolbar.
    View a GridFS file by clicking on the magnifying lens icon in the toolbar
  • Hotkey – F3 (fn + F3 on Mac) [/ht_toggle]

Search for files

Define your search and sort parameters to find particular GridFS files

1. Define the search parameter in the drop-down. Choose from:

  • File search
  • ID search
  • Type search
  • Uploaded before
  • Uploaded after
  • File size smaller
  • File size larger
  • MD5 search

2. Type in the value to look for in the search bar.

3. Define the sort parameter. Choose from:

  • No sort
  • File Name
  • Size
  • File ID
  • File Type
  • Upload Date
  • MD5

4. Click on the Play button to run the search.

To sort results in ascending or descending order, click on the graph icon in the top-right corner.

Sort results in ascending or descending order by clicking on the graph icon

View the GridFS collections

Each GridFS bucket creates two corresponding collections: BucketName.chunks and BucketName.files.

BucketName.chunks contains the actual file chunks:

The chunks collection contains the actual file chunks

While BucketName.files contains the file metadata like filename, uploadDate, and contentType:

The files collection contains the file metadata

Now that you’ve learned how to use GridFS:

Updated on May 24, 2019

Was this article helpful?

Related Articles