s3-gompress

module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2020 License: GPL-3.0

README

s3-gompress

Go Report Card Go license

Simple AWS S3 client with compression/decompression for files

S3-gompressor allows getting and putting objects on S3 without worrying about decompression/compression

Usage
package main

import (
    "github.com/The-Data-Appeal-Company/s3-gompress/client"
    "github.com/The-Data-Appeal-Company/gompressors"
    "github.com/aws/aws-sdk-go/aws/session"
    log "github.com/sirupsen/logrus"
)

func main() {
    sess, err := session.NewSessionWithOptions(session.Options{
        SharedConfigState: session.SharedConfigEnable,
    })
    if err != nil {
        panic(err)
    }
    //using gzip as compression/decompression
    comp := &gompressors.GzipCompressor{}
    s3Client := client.NewS3CompressorClient(sess, "mybucket", comp)
    //put
    err = s3Client.Put("my/key.gz", []byte("LOL"))
    if err != nil {
        log.Errorf("oh no! %v", err)
    } else {
        log.Info("hooray")
    }
    //get
    get, err := s3Client.Get("my/key.gz")
    if err != nil {
        log.Errorf("oh no! %v", err)
    } else {
        log.Info("hooray")
    }
    if string(get) == "LOL" {
        log.Info("it works!")
    }
    //no compression client
    s3ClientPlain := client.NewS3PlainClient(sess, "mybucket")
    err = s3ClientPlain.Put("my/key", []byte("LOL"))
    if err != nil {
        log.Errorf("oh no! %v", err)
    } else {
        log.Info("hooray")
    }
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL