{"id":21586060,"url":"https://github.com/magiclen/mongo-file-center","last_synced_at":"2025-06-19T04:33:55.503Z","repository":{"id":57640062,"uuid":"157702194","full_name":"magiclen/mongo-file-center","owner":"magiclen","description":"To store perennial files and temporary files in MongoDB.","archived":false,"fork":false,"pushed_at":"2024-05-27T09:11:28.000Z","size":1364,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-12T10:07:49.923Z","etag":null,"topics":["mongodb","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/magiclen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-15T11:44:11.000Z","updated_at":"2023-07-31T11:25:30.000Z","dependencies_parsed_at":"2024-11-24T15:22:39.605Z","dependency_job_id":null,"html_url":"https://github.com/magiclen/mongo-file-center","commit_stats":{"total_commits":62,"total_committers":1,"mean_commits":62.0,"dds":0.0,"last_synced_commit":"2bfdb35bd8e97755dfa47152161d1ec13f982228"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/magiclen/mongo-file-center","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fmongo-file-center","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fmongo-file-center/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fmongo-file-center/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fmongo-file-center/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/mongo-file-center/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fmongo-file-center/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260687972,"owners_count":23046821,"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":["mongodb","rust"],"created_at":"2024-11-24T15:12:31.079Z","updated_at":"2025-06-19T04:33:50.474Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"File Center on MongoDB\n====================\n\n[![CI](https://github.com/magiclen/mongo-file-center/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/mongo-file-center/actions/workflows/ci.yml)\n\nThis crate aims to build an easy-to-use and no-redundant file storage based on MongoDB.\n\nFor perennial files, each of them is unique in the database, and can be retrieved many times without limitation.\n\nFor temporary files, they are allowed to be duplicated, but each instance can be retrieved only one time in a minute after it is created.\n\nThe file data can be stored in a document or be separated into chunks to store in multiple documents. It depends on the size of data and the `file_size_threshold`. If the size is smaller than or equal to the threshold, it stores in a single document. The max threshold is **16770KB**. The default threshold is **256KiB**.\n\n## Example\n\n```rust,ignore\nuse mongo_file_center::{FileCenter, FileData, mime};\n\nconst mongodb_uri: \u0026str = \"mongodb://localhost:27017/test_my_file_storage\";\n\nlet file_center = FileCenter::new(mongodb_uri).await.unwrap();\n\nlet file_id = file_center.put_file_by_path(\"/path/to/file\", Some(\"file_name\"), Some(mime::IMAGE_JPEG)).await.unwrap();\n\nlet id_token = file_center.encrypt_id(file_id); // this token is safe in public\n\nlet file_id = file_center.decrypt_id_token(id_token).unwrap();\n\nlet r_file = file_center.get_file_item_by_id(file_id).await.unwrap().unwrap();\n\nmatch r_file.into_file_data() {\n    FileData::Buffer(data) =\u003e {\n        // do something\n    }\n    FileData::Stream(stream) =\u003e {\n        // do something\n    }\n}\n```\n\n## Migration Limitation\n\nThe old file center should not be migrated to the file center 0.6+ because the structure and the hash algorithm have been changed extremely. You will need a lot of effort to do that by yourself.\n\n## Crates.io\n\nhttps://crates.io/crates/mongo-file-center\n\n## Documentation\n\nhttps://docs.rs/mongo-file-center\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fmongo-file-center","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Fmongo-file-center","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fmongo-file-center/lists"}