minio

package
v0.0.0-...-c7114d0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Client *minio.Client

Client minio client

View Source
var Upload = func(r *http.Request, image string) (string, error) {

	idx := strings.Index(image, ";base64,")
	if idx < 0 {
		return "", errors.New("invalid image")
	}
	imageType := image[11:idx]

	unbased, err := base64.StdEncoding.DecodeString(image[idx+8:])
	if err != nil {
		return "", err
	}
	file := bytes.NewReader(unbased)

	fileName := fmt.Sprint(uuid.New(), ".", imageType)

	info, err := Client.PutObject(r.Context(), viper.GetString("minio_bucket"), fileName, file, -1, minio.PutObjectOptions{
		ContentType: "image/" + imageType,
	})
	return info.Location, err
}

Upload uploads the image to minio

Functions

func SetupClient

func SetupClient()

SetupClient setups a minio client

Types

This section is empty.

Jump to

Keyboard shortcuts

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