GridFS Support
Posted on: 02/02/2020 (last updated: 31/08/2021) by Kathryn Vargas- tl;dr
All three Studio 3T editions support GridFS, the method MongoDB uses to store files larger than the document size limit of 16 MB.三个Studio 3T版本都支持GridFS,MongoDB使用GridFS来存储大于16MB文档大小限制的文件。Try it today.
MongoDB and GridFS
GridFS is the file abstraction method MongoDB uses to store and retrieve files larger than 16 MB.GridFS是MongoDB用来存储和检索大于16MB文件的文件抽象方法。
GridFS divides large files into equal chunks with a default size of 255 kB and stores them as a separate document. GridFS将大文件分成相等的块,默认大小为255 kB,并将其存储为单独的文档。The last chunk, however, can be as large as necessary.然而,最后一块可以根据需要任意大。
MongoDB creates two collections to store the files. MongoDB创建两个集合来存储文件。The first collection – 第一个集合chunks
– contains the file chunks; the second – files
– contains the file metadata. chunks
包含文件块;第二个集合files
包含文件元数据。When you search GridDS for a file, the driver will reassemble the chunks as needed.在GridDS中搜索文件时,驱动程序会根据需要重新组合块。
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.GridFS是一种适合在MongoDB中存储文件的机制,它补充了文档模型提供的无模式(因此更快)信息检索。
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 3TStudio 3T中的GridFS支持
In Studio 3T, each database has a corresponding GridFS Buckets folder.在Studio 3T中,每个数据库都有一个对应的GridFS Bucket文件夹。
Within this folder is a default bucket called Images, but you can add more buckets as needed.在这个文件夹中有一个名为Images的默认bucket,但您可以根据需要添加更多bucket。
Add a new GridFS bucket添加一个新的GridFS存储桶

Right-click on the GridFS Buckets folder.右键单击GridFS Bucket文件夹。Choose Add Bucket.选择“添加桶”。Name your bucket.命名桶。Click OK.点击“确定”。
Drop a GridFS bucket扔掉一个GridFS桶
Right-click on the bucket to be deleted.右键单击要删除的bucket。Choose Drop Bucket.选择“删除桶”。
Open GridFS view
Right-click – Right-click on the target GridFS bucket and choose Open GridFS view.右键单击目标GridFS bucket并选择Open GridFS view。

Shortcut – Choose the bucket to view and press Enter选择要查看的铲斗,然后按Enter键

Add a new file
Right-click – Right-click anywhere within the GridFS view and choose Add Files.在GridFS视图中的任意位置单击鼠标右键,然后选择“添加文件”。

Button – Click on the green + sign in the toolbar.单击工具栏中的绿色+符号。

Delete a file删除文件
Right-click – Right-click on the file to be deleted and choose Remove file(s).右键单击要删除的文件,然后选择“删除文件”。

Button – Click on the red – sign in the toolbar.点击工具栏上的红色标志。

Shortcut – ⌫ (fn + ⌫ on Mac)
Save a file保存文件
Right-click – Right-click on the file you want to save and choose Save to Disk.右键单击要保存的文件,然后选择“保存到磁盘”。

Button – Click on the disk icon in the toolbar.单击工具栏中的磁盘图标。

Shortcut快捷键 – Ctrl + S (⌘ + S)
View a file查看文件
Right-click右击 – Right-click on the file you want to view and choose View File.右键单击要查看的文件,然后选择“查看文件”。

Button按钮 – Choose the file you want to view and click on the lens icon in the toolbar.选择要查看的文件,然后单击工具栏中的镜头图标。

Shortcut快捷键 – F3 (fn + F3 on Mac)
Search for files搜索文件

1. Define the search parameter in the drop-down. 在下拉列表中定义搜索参数。Choose from:选择:
File search文件搜索ID searchID搜索- 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.按升序或降序排序,单击右上角的图形图标。
View the GridFS collections查看GridFS集合
Each GridFS bucket creates two corresponding collections: BucketName.chunks and BucketName.files.每个GridFS bucket创建两个对应的集合:BucketName.chunks
和BucketName.files
。
BucketName.chunks contains the actual file chunks:BucketName.chunks
包含实际的文件块:

While BucketName.files contains the file metadata like filename, uploadDate, and contentType:BucketName.files
包含文件名、上载日期和内容类型等文件元数据:

Now that you’ve learned how to use GridFS:现在,您已经了解了如何使用GridFS:
Explore Studio 3T’s wide range of MongoDB import and export options探索Studio 3T广泛的MongoDB导入和导出选项Create your very first MongoDB view to make querying much faster创建您的第一个MongoDB视图,以加快查询速度