Skip to content

bpicolo/Bulletin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bulletin

Build Status Nuget

Bulletin is an in-progress library that simplifies file storage and processing for Dotnet Core projects using ASP.NET and Entity Framework Core.

Getting Started

First, you'll need to update your EF Database context to support Bulletin's Attachment model.

using Bulletin.EFCore;
using Bulletin.Models;

class MyDatabaseContext : IBulletinDbContext {
    
    public DbSet<Attachment> Attachments { get; set; }
    
    protected override void OnModelCreating(ModelBuilder modelBuilder) {
        base.OnModelCreating(modelBuilder);
        modelBuilder.ApplyConfiguration(new AttachmentEntityTypeConfiguration());
    }
}

Next, configure ASP.NET application startup with Bulletin.

using Bulletin;
using Bulletin.AspNetCore;
using Bulletin.Storage.File;
...
public class Startup {

    public void ConfigureServices(IServiceCollection services)
        services.AddBulletin<MyDatabaseContext>(b => {
            b.AddBoard(
                "images",
                new FileStorage(
                    new FileStorageOptions("./tmp/storage")
                )
            )
        })
    }
}

Bulletin will setup a service provider for easy access to storage boards.

class MyController {
    private readonly IBulletinBoard _imagesBoard;
    
    public MyController(IBulletin bulletin) {
        _imagesBoard = bulletin.GetBoard("images");
    }

    [HttpPost()]
    public Task<Attachment> UploadImage(IFormFile file) {
        return await _imagesBoard.AttachAsync(file.FileName, file.OpenReadStream());
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages