ginupload

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ginupload implements gin handlers for file upload processing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	upload.Config
	Path        string `long:"path" default:"/img" description:"Image URL path"`
	UploadPath  string `long:"upload_path" default:"/upload" description:"Image upload URL path"`
	PreviewPath string `long:"preview_path" default:"/preview" description:"Preview image URL path"`
}

Config holds all config vars

type File

type File struct {
	Name string `form:"name" json:"name" binding:"required"`
	Data string `form:"data" json:"data" binding:"required"`
}

File hold JSON request struct

type Service

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

Service holds ginupload service

func New

func New(cfg Config, log loggers.Contextual, upl Uploader) *Service

New creates a Service object

func (Service) HandleBase64

func (srv Service) HandleBase64(c *gin.Context)

HandleBase64 reads POST with JSON data (data:image/png;base64,...) and returns JSON with links to file and preview

func (Service) HandleMultiPart

func (srv Service) HandleMultiPart(c *gin.Context)

HandleMultiPart handles a file received as multipart form

func (Service) HandleURL

func (srv Service) HandleURL(c *gin.Context)

HandleURL handles an image from url field

type Uploader

type Uploader interface {
	HandleMultiPart(form *multipart.Form) (*string, error)
	HandleURL(url string) (*string, error)
	HandleBase64(data, name string) (*string, error)
}

Uploader holds methods of underlying upload package

Jump to

Keyboard shortcuts

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