All Projects → chartmuseum → storage

chartmuseum / storage

Licence: Apache-2.0 license
Go library providing common interface for working across multiple cloud storage backends

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to storage

go-storage
A vendor-neutral storage library for Golang: Write once, run on every storage service.
Stars: ✭ 387 (+151.3%)
Mutual labels:  storage, s3, gcs
Goofys
a high-performance, POSIX-ish Amazon S3 file system written in Go
Stars: ✭ 3,932 (+2453.25%)
Mutual labels:  s3, gcs, azure-blob
hub
Public reusable components for Polyaxon
Stars: ✭ 8 (-94.81%)
Mutual labels:  s3, gcs
ob bulkstash
Bulk Stash is a docker rclone service to sync, or copy, files between different storage services. For example, you can copy files either to or from a remote storage services like Amazon S3 to Google Cloud Storage, or locally from your laptop to a remote storage.
Stars: ✭ 113 (-26.62%)
Mutual labels:  s3, oracle-cloud
esop
Cloud-enabled backup and restore tool for Apache Cassandra
Stars: ✭ 40 (-74.03%)
Mutual labels:  storage, s3
Cloudexplorer
Cloud Explorer
Stars: ✭ 170 (+10.39%)
Mutual labels:  storage, s3
Tus Ruby Server
Ruby server for tus resumable upload protocol
Stars: ✭ 172 (+11.69%)
Mutual labels:  storage, s3
BlobHelper
BlobHelper is a common, consistent storage interface for Microsoft Azure, Amazon S3, Komodo, Kvpbase, and local filesystem written in C#.
Stars: ✭ 23 (-85.06%)
Mutual labels:  storage, s3
Noobaa Core
NooBaa is a Dynamic Data Gateway for cloud-native, hybrid and multi cloud environments ☁️🚀
Stars: ✭ 131 (-14.94%)
Mutual labels:  storage, s3
sftp-gateway
This repository contains a docker image configured to use the SSH File Transfer Protocol (SFTP) to transfer all its files to Cloud Blob Storage Services. This image can be deployed on a Kubernetes cluster with Helm.
Stars: ✭ 18 (-88.31%)
Mutual labels:  s3, gcs
gcsfs
Google Cloud Storage filesystem for PyFilesystem2
Stars: ✭ 36 (-76.62%)
Mutual labels:  storage, gcs
go-fsimpl
Go io/fs.FS filesystem implementations for various URL schemes
Stars: ✭ 225 (+46.1%)
Mutual labels:  s3, gcs
Uptoc
A static file deployment tool that supports multiple platforms./ 一个支持多家云厂商的静态文件部署工具
Stars: ✭ 159 (+3.25%)
Mutual labels:  storage, s3
Pins
Pin, Discover and Share Resources
Stars: ✭ 149 (-3.25%)
Mutual labels:  storage, s3
Cakephp File Storage
Abstract file storage and upload plugin for CakePHP. Write to local disk, FTP, S3, Dropbox and more through a single interface. It's not just yet another uploader but a complete storage solution.
Stars: ✭ 202 (+31.17%)
Mutual labels:  storage, s3
Mc
MinIO Client is a replacement for ls, cp, mkdir, diff and rsync commands for filesystems and object storage.
Stars: ✭ 1,962 (+1174.03%)
Mutual labels:  storage, s3
awesome-storage
A curated list of storage open source tools. Backups, redundancy, sharing, distribution, encryption, etc.
Stars: ✭ 324 (+110.39%)
Mutual labels:  storage, s3
Cash
HTTP response caching for Koa. Supports Redis, in-memory store, and more!
Stars: ✭ 122 (-20.78%)
Mutual labels:  storage, s3
Ghost Storage Adapter S3
An AWS S3 storage adapter for Ghost
Stars: ✭ 128 (-16.88%)
Mutual labels:  storage, s3
gcp-storage-emulator
Local emulator for Google Cloud Storage
Stars: ✭ 43 (-72.08%)
Mutual labels:  storage, gcs

chartmuseum/storage

GitHub Actions status Go Report Card GoDoc

Go library providing a common interface for working across multiple storage backends.

Supported storage backends:

This code was originally part of the Helm project: ChartMuseum, but has since been released as a standalone package for others to use in their own projects.

Primary Components

Backend (interface)

Backend is a common interface that is implemented by all the supported storage backends and their associated types:

type Backend interface {
    ListObjects(prefix string) ([]Object, error)
    GetObject(path string) (Object, error)
    PutObject(path string, content []byte) error
    DeleteObject(path string) error
}

Object (struct)

Object is a struct that represents a single storage object:

type Object struct {
    Path         string
    Content      []byte
    LastModified time.Time
}

ObjectSliceDiff (struct)

ObjectSliceDiff is a struct that represents overall changes between two Object slices:

type ObjectSliceDiff struct {
    Change  bool
    Removed []Object
    Added   []Object
    Updated []Object
}

GetObjectSliceDiff (function)

GetObjectSliceDiff is a function that takes two Object slices, compares them, and returns an ObjectSliceDiff:

func GetObjectSliceDiff(prev []Object, curr []Object, timestampTolerance time.Duration) ObjectSliceDiff

Usage

Simple example

The following is a simple program that will upload a file either to an Azure Blob Storage bucket (container) or a Google Cloud Storage bucket based on the command line options provided:

// Usage: go run example.go <cloud> <bucket> <file>

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"

	"github.com/chartmuseum/storage"
)

type (
	Uploader struct {
		Backend storage.Backend
	}
)

func NewUploader(cloud string, bucket string) *Uploader {
	var backend storage.Backend
	switch cloud {
	case "azure":
		backend = storage.NewMicrosoftBlobBackend(bucket, "")
	case "google":
		backend = storage.NewGoogleCSBackend(bucket, "")
	default:
		panic("cloud provider " + cloud + " not supported")
	}
	uploader := Uploader{Backend: backend}
	fmt.Printf("uploader created (cloud: %s, bucket: %s)\n", cloud, bucket)
	return &uploader
}

func (uploader *Uploader) Upload(filename string) {
	basename := filepath.Base(filename)
	content, err := ioutil.ReadFile(filename)
	if err != nil {
		panic(err)
	}
	err = uploader.Backend.PutObject(basename, content)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s successfully uploaded\n", basename)
}

func main() {
	args := os.Args[1:]
	uploader := NewUploader(args[0], args[1])
	uploader.Upload(args[2])
}

Example of using to upload the file index.html to an Azure bucket:

go run example.go azure mycontainer index.html

Example of using to upload the file index.html to a Google Cloud bucket:

go run example.go google mybucket index.html

Per backend

Each supported storage backend has its own type that implements the Backend interface. All available types are described in detail on GoDoc.

In addition, authentication methods are based on the runtime environment and vary from cloud to cloud.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].