storagecs3

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 10 Imported by: 0

README

Module Storage

Storage APIs
GET /api/v1/storage/presigned-url
PUT /api/v1/storage/legitimize-files	
Usage

Install

go get -u github.com/gflydev/modules/storages3@v1.0.0

File main.go

import (
    _ "github.com/gflydev/storage/s3"
)

File api_routes.go

import "github.com/gflydev/modules/storages3/api"

// `API` Router
g.Group(prefixAPI, func(apiRouter *core.Group) {
    /* ============================ Storage Group ==========================================*/
    apiRouter.Group("/storage", func(uploadGroup *core.Group) {
        uploadGroup.GET("/presigned-url", api.NewPresignedURLApi())      // Get presigned URL
        uploadGroup.PUT("/legitimize-files", api.NewLegitimizeFileApi()) // Legitimize uploaded file
    })
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LegitimizeFiles

func LegitimizeFiles(files []dto.LegitimizeItem) []dto.LegitimizeItem

LegitimizeFiles make file list available

func PresignedURL

func PresignedURL(objectKey string) (string, string, error)

PresignedURL generate pre-signed upload URL from Local storage

Types

type PreSigner

type PreSigner struct {
	MinioClient *minio.Client
}

PreSigner encapsulates the MinIO/S3 preSigned actions used in the examples. It contains MinioClient, a client that is used to preSigned requests to S3-compatible storage. PreSigned requests contain temporary credentials and can be made from any HTTP client.

func (PreSigner) DeleteObject

func (preSigner PreSigner) DeleteObject(bucketName, objectKey string) (*PresignedHTTPRequest, error)

DeleteObject makes a preSigned request that can be used to delete an object from a bucket. Note: MinIO doesn't support presigned DELETE operations, so this method performs direct deletion

func (PreSigner) GetObject

func (preSigner PreSigner) GetObject(
	bucketName, objectKey string, lifetimeSecs int64) (*PresignedHTTPRequest, error)

GetObject makes a preSigned request that can be used to get an object from a bucket. The preSigned request is valid for the specified number of seconds.

func (PreSigner) PutObject

func (preSigner PreSigner) PutObject(
	bucketName, objectKey string, lifetimeSecs int64) (*PresignedHTTPRequest, error)

PutObject makes a preSigned request that can be used to put an object in a bucket. The preSigned request is valid for the specified number of seconds.

type PresignedHTTPRequest added in v1.1.0

type PresignedHTTPRequest struct {
	URL string
}

PresignedHTTPRequest represents a presigned HTTP request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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