Coder Social home page Coder Social logo

ttiventures / buffalo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 153 KB

Buffalo allows Upload your Favorite Files via this Awesome Library for Objects

License: GNU Lesser General Public License v3.0

C# 98.18% Dockerfile 1.82%
bucket cloud-storage s3 s3-storage cloud storage objectstorage

buffalo's Introduction

by TTI Ventures


Buffalo allows Upload your Favorite Files via this Awesome Library for Objects

Buffalo is a library for .NET that ease the management of static objects and files in the cloud by abstracting each service's own libraries and presenting a simple and lightweight common interface.

Additionally, Buffalo adds a security layer that allows you to control access or deletion of your files, as well as distribute them publicly through the cloud CDN.

At the moment only Google Cloud Storage and Amazon S3 are supported.

Features

  • Static object management in the cloud (Upload, Delete, Download).
  • Multi-cloud implementation (Cloud Storage and Amazon S3).
  • Per-user object access level.
  • Automatic public ACL management.
  • Easy configuration.
  • No database or local storage required.

Setup

Use the AddBuffalo extension method for IServiceCollection to configure the library host upon startup of your application. Depending on the cloud storage service you want to use, different parameters must be provided.

Google Cloud Storage

The following parameters are required to use Google Cloud Storage:

  • JsonCredentialsFile: Google Cloud service account key in JSON format.
  • StorageBucket: Google Cloud Storage bucket in which the library will operate.
services.AddBuffalo(x =>
{    
    x.UseCloudStorage(h =>
    {
        h.JsonCredentialsFile = <SERVICE_ACCOUNT_KEY>;
        h.StorageBucket = <STORAGE_BUCKET_NAME>;
    });
});

Amazon S3

The following parameters are required to use Amazon S3:

  • AccessKey: ID key of your AWS Credentials.
  • SecretKey: Secret key of your AWS Credentials.
  • BucketName: Amazon S3 bucket in which the library will operate.
  • FolderName: Folder inside bucket in in which the library will operate.
  • RegionEndpoint: AWS Region by system name in which the library will operate (like "us-west-1").
services.AddBuffalo(x =>
{
    x.UseAmazonS3(y =>
    {
        y.AccessKey = <AWS_ID_KEY>;
        y.SecretKey = <AWS_SECRET_KEY>;
        y.BucketName = <S3_BUCKET_NAME>;
        y.FolderName = <FOLDER_NAME>;
        y.RegionEndpoint = <AWS_S3_REGION>;
    });
});

Usage

When your application starts, grab the Buffalo library from the built-in dependency injection and you will be able to use the FileManager from any class, controller, etc...

private readonly FileManager _fileManager;

public MyFunction(FileManager fileManager)
{
    _fileManager = fileManager;
}

An example project is included in which the library is used as part of a controller.

Upload File

  • file (IFormFile): File to be upload in IFormFile structure.
  • user (string?): User id uploading the file.
  • accessLevel (AccessLevels): PUBLIC, PRIVATE or PROTECTED type access level in AccessLevels enum.
await _fileManager.UploadFile(file, user, accessLevel);

Delete File

  • id (Guid): Id of the object to be deleted.
  • user (string?): User id deleting the file.
bool deleted = await _fileManager.DeleteFile(id, user);

Download File

  • id (Guid): Id of the object to be retrieved.
  • user (string?): User id downloading the file.
var file = await _fileManager.GetFile(id, user);

buffalo's People

Contributors

aeri avatar devidence7 avatar osjimenez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.