minio/

directory
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT

README

PTGU Storage Minio

Import

import (
  PTGUstorage "github.com/parinyapt/golang_utils/storage/minio/v1"
)

Example

Config Minio
minioClient, err := minio.New("MINIO_ENDPOINT", &minio.Options{
  Creds:  credentials.NewStaticV4("MINIO_ACCESS_KEY", "MINIO_SECRET_ACCESS_KEY", ""),
  Secure: false,
})
if err != nil {
  panic(err)
}

minioUtils := PTGUstorage.NewStorageMinio(minioClient)

Upload Image From URL with Resize

  • StoragePutObjectOptions is optional
  • ResizeConfig is optional
  • ResizeConfig is required Width and Height if you want to resize image, if not it will upload original image
uploadInfo, err := minioUtils.UploadImageFromURL(PTGUstorage.ParamUploadImageFromURL{
  StorageBucket:     "MINIO_BUCKET",
  StorageObjectName: "MINIO_OBJECT_NAME",
  StoragePutObjectOptions: &minio.PutObjectOptions{
    ContentType: "CONTENT_TYPE",
  },
  ImageURL:          "IMAGE_URL",
  ResizeConfig:      &PTGUstorage.ParamUploadImageFromURLresizeConfig{
    Width: 100, 
    Height: 100,
  },
})

if err != nil {
  panic(err)
}

fmt.Println(uploadInfo)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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