{"id":21599466,"url":"https://github.com/sitholewb/files.entityframeworkcore.extensions","last_synced_at":"2025-07-27T02:34:35.069Z","repository":{"id":162590173,"uuid":"625329848","full_name":"SitholeWB/Files.EntityFrameworkCore.Extensions","owner":"SitholeWB","description":"This is a library for storing files in small chunks on sql using EntityFrameworkCore. Works well with Entity Framework as an extension.","archived":false,"fork":false,"pushed_at":"2023-09-02T12:29:36.000Z","size":1083,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-07T08:55:05.969Z","etag":null,"topics":["blob-storage","bytes","entity-framework-core","extensions","file-upload","files","images","storage"],"latest_commit_sha":null,"homepage":"","language":"C#","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/SitholeWB.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,"zenodo":null}},"created_at":"2023-04-08T19:23:48.000Z","updated_at":"2024-08-07T00:54:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"99bb6a1a-7ebc-417f-a1b4-e16547a65dff","html_url":"https://github.com/SitholeWB/Files.EntityFrameworkCore.Extensions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SitholeWB/Files.EntityFrameworkCore.Extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FFiles.EntityFrameworkCore.Extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FFiles.EntityFrameworkCore.Extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FFiles.EntityFrameworkCore.Extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FFiles.EntityFrameworkCore.Extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SitholeWB","download_url":"https://codeload.github.com/SitholeWB/Files.EntityFrameworkCore.Extensions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SitholeWB%2FFiles.EntityFrameworkCore.Extensions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267289402,"owners_count":24064726,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["blob-storage","bytes","entity-framework-core","extensions","file-upload","files","images","storage"],"created_at":"2024-11-24T18:15:27.273Z","updated_at":"2025-07-27T02:34:35.063Z","avatar_url":"https://github.com/SitholeWB.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Files.EntityFrameworkCore.Extensions\n\nThis is a library for storing files in small chunks on sql using EntityFrameworkCore.\nWorks well with **Entity Framework** as an extension.\n\n# Get Started\n\n```nuget\nInstall-Package Files.EntityFrameworkCore.Extensions\n```\n\n# Example\n### More examples found inside the repository \n```C#\n  \n  \tpublic class UserImage : IFileEntity\n\t{\n\t\tpublic Guid Id { get; set; }\n\t\tpublic Guid FileId { get; set; }\n\t\tpublic string Name { get; set; }\n\t\tpublic string MimeType { get; set; }\n\t\tpublic DateTimeOffset TimeStamp { get; set; }\n\t\tpublic Guid? NextId { get; set; }\n\t\tpublic int ChunkBytesLength { get; set; }\n\t\tpublic long TotalBytesLength { get; set; }\n\t\tpublic byte[] Data { get; set; }\n\t}\n\t\n\tpublic class UploadFileIdCommand\n    \t{\n        \tpublic Guid? FileId { get; set; }\n    \t}\n\t\n\tpublic class UploadCommand\n\t{\n\t\tpublic IFormFile File { get; set; }\n\t}\n  \n  \tpublic class WebApiContext : DbContext\n\t{\n\t\tpublic WebApiContext(DbContextOptions\u003cWebApiContext\u003e options)\n\t\t\t: base(options)\n\t\t{\n\t\t}\n\t\tpublic DbSet\u003cUserImage\u003e UserImage { get; set; }\n\t}\n  \n        [Route(\"api/user-images\")]\n\t[ApiController]\n\tpublic class UserImagesController : ControllerBase\n\t{\n\t\tprivate readonly WebApiContext _context;\n\n\t\tpublic UserImagesController(WebApiContext context)\n\t\t{\n\t\t\t_context = context;\n\t\t}\n\n\t\t[HttpPost]\n\t\t[DisableRequestSizeLimit]\n\t\tpublic async Task\u003cActionResult\u003cFilesExtensionsResponse\u003e\u003e UploadFile([FromForm] UploadCommand uploadCommand)\n\t\t{\n\t\t\tvar file = uploadCommand.File;\n\t\t\tif (file.Length \u003e 0)\n\t\t\t{\n\t\t\t\tvar fileDetails = await _context.SaveFileAsync\u003cUserImage\u003e(file.OpenReadStream(), file.FileName, file.ContentType);\n\t\t\t\treturn Ok(fileDetails);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn BadRequest(\"File is required.\");\n\t\t\t}\n\t\t}\n\t\t\n\t\t[HttpPost(\"other-file\")]\n        \tpublic async Task\u003cActionResult\u003cFilesExtensionsResponse\u003e\u003e UploadOtherFile([FromBody] UploadFileIdCommand command)\n        \t{\n\t\t\t//The @\"appsettings.json\" is a path to any file you will like to save\n            \t\tvar fileDetails = await _context.SaveFileAsync\u003cUserImage\u003e(@\"appsettings.json\", command?.FileId);\n\t\t\t//Save will be auto called on every chunk addition so that memory usage remain low, i.e. await _context.SaveChangesAsync();\n            \t\treturn Ok(fileDetails);\n        \t}\n\n\t\t[HttpGet(\"{id}/download\")]\n\t\tpublic async Task\u003cIActionResult\u003e DownLoadFile(Guid id)\n\t\t{\n\t\t\tvar fileDetails = await _context.GetFileInfoAsync\u003cUserImage\u003e(id);\n\t\t\tvar stream = new MemoryStream();\n\t\t\tawait _context.DownloadFileToStreamAsync\u003cUserImage\u003e(id, stream);\n\t\t\treturn File(stream, fileDetails.MimeType, fileDetails.Name);\n\t\t}\n\n\t\t[HttpGet(\"{id}/view\")]\n\t\tpublic async Task\u003cFileStreamResult\u003e DownloadView(Guid id)\n\t\t{\n\t\t\tvar fileDetails = await _context.GetFileInfoAsync\u003cUserImage\u003e(id);\n\t\t\tvar stream = new MemoryStream();\n\t\t\tawait _context.DownloadFileToStreamAsync\u003cUserImage\u003e(id, stream);\n\t\t\treturn new FileStreamResult(stream, fileDetails.MimeType);\n\t\t}\n\n\t\t[HttpDelete(\"{id}\")]\n\t\tpublic async Task\u003cIActionResult\u003e DeleteUserImage(Guid id)\n\t\t{\n\t\t\tif (_context.UserImage == null)\n\t\t\t{\n\t\t\t\treturn NotFound();\n\t\t\t}\n\t\t\tvar userImage = await _context.UserImage.FindAsync(id);\n\t\t\tif (userImage == null)\n\t\t\t{\n\t\t\t\treturn NotFound();\n\t\t\t}\n\n\t\t\tawait _context.DeleteFileAsync\u003cUserImage\u003e(id);\n\t\t\t//Save will be auto called on every chunk deletion so that memory usage remain low, i.e. await _context.SaveChangesAsync();\n\n\t\t\treturn NoContent();\n\t\t}\n\t}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitholewb%2Ffiles.entityframeworkcore.extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsitholewb%2Ffiles.entityframeworkcore.extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsitholewb%2Ffiles.entityframeworkcore.extensions/lists"}