server

package
v0.0.0-...-151ab5d Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: AGPL-3.0-or-later Copyright (C) 2024 Japan7

SPDX-License-Identifier: AGPL-3.0-or-later Copyright (C) 2024 Japan7

SPDX-License-Identifier: AGPL-3.0-or-later Copyright (C) 2024 Japan7

SPDX-License-Identifier: AGPL-3.0-or-later Copyright (C) 2024 Japan7

SPDX-License-Identifier: AGPL-3.0-or-later Copyright (C) 2024 Japan7

Index

Constants

This section is empty.

Variables

View Source
var BEARER_PREFIX = "Bearer "
View Source
var CONFIG = getProducerConfig()
View Source
var S3_BEST_CLIENT *minio.Client
View Source
var S3_CLIENTS map[string]*minio.Client = map[string]*minio.Client{}

Functions

func CreateTempFile

func CreateTempFile(ctx context.Context, tempfile *UploadTempFile, reader io.Reader) error

func DeleteObject

func DeleteObject(ctx context.Context, filename string) error

func Download

func Download(ctx context.Context, input *DownloadInput) (*huma.StreamResponse, error)

func GetFileObject

func GetFileObject(ctx context.Context, filename string) (*minio.Object, error)

func MakeCli

func MakeCli()

func RunProducer

func RunProducer(app *fiber.App, api huma.API)

func SetupProducer

func SetupProducer() (*fiber.App, huma.API)

func UploadToS3

func UploadToS3(ctx context.Context, file io.Reader, file_id string, filename string, filesize int64, content_type string, expires time.Time) error

Types

type DownloadHeadOutput

type DownloadHeadOutput struct {
	AcceptRange   string `header:"Accept-Range"`
	ContentLength int64  `header:"Content-Length"`
	ContentType   string `header:"Content-Type"`
	Expires       int64  `header:"Expires"`
}

func DownloadHead

func DownloadHead(ctx context.Context, input *DownloadInput) (*DownloadHeadOutput, error)

type DownloadInput

type DownloadInput struct {
	Filename    string `path:"id" example:"1.webm"`
	Range       string `header:"Range"`
	IfNoneMatch string `header:"If-None-Match"`
}

type FileSender

type FileSender struct {
	// Reader should be already at the Range.Start location
	Fd        io.ReadCloser
	Range     httputils.Range
	BytesRead uint64
}

func (*FileSender) Close

func (f *FileSender) Close() error

func (*FileSender) Read

func (f *FileSender) Read(buf []byte) (int, error)

type ProducerConfig

type ProducerConfig struct {
	Listen ProducerListenConfig `env_prefix:"LISTEN"`
	Upload ProducerUploadConfig `env_prefix:"UPLOAD"`
	S3     ProducerS3Config     `env_prefix:"S3"`
}

type ProducerListenConfig

type ProducerListenConfig struct {
	Host string `envkey:"HOST" default:"0.0.0.0"`
	Port int    `envkey:"PORT" default:"8140"`
}

func (ProducerListenConfig) Addr

func (c ProducerListenConfig) Addr() string

type ProducerS3Config

type ProducerS3Config struct {
	// S3 hosts
	Endpoints []string `envkey:"ENDPOINT" separator:" "`
	// use HTTPS
	Secure     bool   `envkey:"SECURE"`
	KeyID      string `envkey:"KEYID"`
	Secret     string `envkey:"SECRET"`
	BucketName string `envkey:"BUCKET_NAME" default:"producer"`
}

type ProducerUploadConfig

type ProducerUploadConfig struct {
	BodyLimit int    `envkey:"BODY_LIMIT" default:"1073741824"`
	BaseURL   string `envkey:"BASE_URL"`
	// Default expiration time in seconds
	DefaultExpirationTime int    `envkey:"DEFAULT_EXPIRATION_TIME" default:"1800"`
	AdminToken            string `envkey:"ADMIN_TOKEN"`
}

type TestedClient

type TestedClient struct {
	Client      *minio.Client
	ListLatency int64
}

type UploadData

type UploadData struct {
	UploadFile multipart.File `form-data:"file" required:"true"`
}

type UploadInput

type UploadInput struct {
	Auth     string `header:"Authorization"`
	Expires  int64  `header:"Expires"`
	FileName string `header:"Filename"`
	File     UploadTempFile
}

func (*UploadInput) Resolve

func (i *UploadInput) Resolve(ctx huma.Context) []error

type UploadInputDefinition

type UploadInputDefinition struct {
	Auth     string `header:"Authorization"`
	Expires  int64  `header:"Expires"`
	FileName string `header:"Filename"`
	RawBody  huma.MultipartFormFiles[UploadData]
}

type UploadOutput

type UploadOutput struct {
	Body struct {
		ID      string `json:"id"`
		URL     string `json:"url"`
		Expires int64  `json:"expires"`
	}
}

func Upload

func Upload(ctx context.Context, input *UploadInput) (*UploadOutput, error)

type UploadTempFile

type UploadTempFile struct {
	Fd    *os.File
	Size  int64
	CRC32 uint32
}

Jump to

Keyboard shortcuts

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