fsutils

package
v0.0.0-...-94dd30a Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(region, bucket, key, secret string) *Service

NewService creates a new fileutils Service instance that can be used to upload, download, and delete files from S3.

func (*Service) DeleteFile

func (s *Service) DeleteFile(fileName string) error

DeleteFile deletes a file from S3.

func (*Service) DeleteFiles

func (s *Service) DeleteFiles(fileNames []string) error

/ DeleteFiles deletes multiple files from S3.

func (*Service) DownloadFile

func (s *Service) DownloadFile(fileName string) ([]byte, error)

DownloadFile downloads a file.

handler code:

// Set headers for the response
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName))
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Length", fmt.Sprintf("%d", len(buf.Bytes())))

// Write the file to the response
_, err = w.Write(buf.Bytes())
if err != nil {
	http.Error(w, "Failed to write file to response", http.StatusInternalServerError)
	return
}

func (*Service) UploadFile

func (s *Service) UploadFile(fileName string, file io.Reader) (string, error)

UploadFile uploads a file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳