{"id":19777979,"url":"https://github.com/shrinerb/shrine-gridfs","last_synced_at":"2025-06-19T01:38:10.919Z","repository":{"id":56895445,"uuid":"48258076","full_name":"shrinerb/shrine-gridfs","owner":"shrinerb","description":"MongoDB's GridFS storage for Shrine","archived":false,"fork":false,"pushed_at":"2023-01-18T13:11:09.000Z","size":37,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-21T21:24:32.219Z","etag":null,"topics":["chunk","file","gridfs","mongodb","shrine","storage"],"latest_commit_sha":null,"homepage":"https://docs.mongodb.com/manual/core/gridfs/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shrinerb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-18T21:52:09.000Z","updated_at":"2024-12-26T16:19:06.000Z","dependencies_parsed_at":"2023-02-10T15:15:47.010Z","dependency_job_id":null,"html_url":"https://github.com/shrinerb/shrine-gridfs","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrinerb%2Fshrine-gridfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrinerb%2Fshrine-gridfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrinerb%2Fshrine-gridfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shrinerb%2Fshrine-gridfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shrinerb","download_url":"https://codeload.github.com/shrinerb/shrine-gridfs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250949619,"owners_count":21512537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chunk","file","gridfs","mongodb","shrine","storage"],"created_at":"2024-11-12T05:27:19.294Z","updated_at":"2025-04-30T20:30:34.807Z","avatar_url":"https://github.com/shrinerb.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shrine::Storage::Gridfs\n\nProvides MongoDB's [GridFS] storage for [Shrine].\n\nGridFS is a specification for storing and retrieving files in chunks, and is\nconvenient when MongoDB is already used in the application.\n\n## Installation\n\n```ruby\n# Gemfile\ngem \"shrine-gridfs\", \"~\u003e 1.0\"\n```\n\n## Usage\n\nYou can initialize the GridFS storage with a Mongo connection:\n\n```rb\nrequire \"shrine/storage/gridfs\"\n\nclient = Mongo::Client.new(\"mongodb://127.0.0.1:27017/mydb\")\nShrine::Storage::Gridfs.new(client: client)\n```\n\n### Prefix\n\nThe default prefix (bucket name) is \"fs\", you can change it with the `:prefix`\noption, which is useful if you want to separate temporary and permanent storage.\n\n```rb\nShrine.storages = {\n  cache: Shrine::Storage::Gridfs.new(prefix: \"temp\", **options),\n  store: Shrine::Storage::Gridfs.new(prefix: \"fs\", **options),\n}\n```\n\n### Chunk size\n\nBy default the Gridfs storage will store files in chunks of 256KB, you can\nchange that via `:chunk_size`:\n\n```rb\nShrine::Storage::Gridfs.new(chunk_size: 1*1024*1024, **options) # 1MB\n```\n\n### Batch size\n\nWhen Gridfs storage uploads or copies a file, it will ensure that no more\nthan `:batch_size` of data is loaded into memory at once (defaults to 5MB).\n\n```rb\nShrine::Storage::Gridfs.new(batch_size: 10*1024*1024, **options) # 10MB\n```\n\n### URLs\n\nYou can generate URLs through which the GridFS files will be streamed with the\n`download_endpoint` plugin:\n\n```rb\nShrine.plugin :download_endpoint, storages: [:store]\n```\n```rb\nRails.application.routes.draw do\n  mount Shrine.download_endpoint =\u003e \"/attachments\"\nend\n```\n```rb\nuser.avatar_url #=\u003e \"/attachments/store/9k30fks72j8.jpg\"\n```\n\n## Development\n\nYou can run the tests with Rake:\n\n```rb\n$ bundle exec rake test\n```\n\n## Inspiration\n\nThis gem was inspired by [refile-gridfs].\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n\n[GridFS]: https://docs.mongodb.org/v3.0/core/gridfs/\n[Shrine]: https://github.com/shrinerb/shrine\n[refile-gridfs]: https://github.com/Titinux/refile-gridfs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshrinerb%2Fshrine-gridfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshrinerb%2Fshrine-gridfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshrinerb%2Fshrine-gridfs/lists"}