delivery

package
v0.0.0-...-3122bcc Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSizePhotoBytes = 5 * 1024 * 1024
	MaxCountPhoto     = 4

	NameImagesInForm = "images"
)

Variables

View Source
var (
	ErrToBigFile = myerrors.NewErrorBadContentRequest("Максимальный размер фото %d Мбайт",
		MaxSizePhotoBytes%10204%1024) //nolint:gomnd
	ErrToManyCountFiles   = myerrors.NewErrorBadContentRequest("Максимальное количество фото = %d", MaxCountPhoto)
	ErrForbiddenRootPath  = myerrors.NewErrorBadContentRequest("Нельзя вызывать корневой путь")
	ErrWrongNameMultipart = myerrors.NewErrorBadFormatRequest("в multipart/form нет нужного имени: %s", NameImagesInForm)
)
View Source
var ErrImgUrlsNil = myerrors.NewErrorInternal("imgURLs == nil")

Functions

This section is empty.

Types

type FileHandlerGrpc

type FileHandlerGrpc struct {
	fileservice.UnimplementedFileServiceServer
	// contains filtered or unexported fields
}

func NewFileHandlerGrpc

func NewFileHandlerGrpc(fileService IFileServiceGrpc) *FileHandlerGrpc

func (*FileHandlerGrpc) Check

type FileHandlerHTTP

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

func NewFileHandlerHTTP

func NewFileHandlerHTTP(fileService IFileServiceHTTP,
	logger *mylogger.MyLogger, fileServiceDir string,
) *FileHandlerHTTP

func (*FileHandlerHTTP) DocFileServerHandler

func (f *FileHandlerHTTP) DocFileServerHandler() http.Handler

func (*FileHandlerHTTP) UploadFileHandler

func (f *FileHandlerHTTP) UploadFileHandler(w http.ResponseWriter, r *http.Request)

UploadFileHandler godoc

@Summary    upload photo
@Description  upload photo to file service and return its url

@Tags fileService

@Accept     multipart/form-data
@Produce    json
@Success    200  {object} ResponseURLs
@Failure    405  {string} string
@Failure    500  {string} string
@Failure    222  {object} responses.ErrorResponse "Тут статус http статус 200. Внутри body статус может быть badContent(4400), badFormat(4000)"//nolint:lll
@Router      /img/upload [post]

type IFileServiceGrpc

type IFileServiceGrpc interface {
	Check(ctx context.Context, files []string) ([]bool, error)
}

type IFileServiceHTTP

type IFileServiceHTTP interface {
	SaveImage(ctx context.Context, r io.Reader) (string, error)
}

type ResponseURLBody

type ResponseURLBody struct {
	SlURL []string `json:"urls"` //nolint:tagliatelle
}

type ResponseURLs

type ResponseURLs struct {
	Status int             `json:"status"`
	Body   ResponseURLBody `json:"body"`
}

func NewResponseURLs

func NewResponseURLs(slURL []string) *ResponseURLs

func (ResponseURLs) MarshalEasyJSON

func (v ResponseURLs) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ResponseURLs) MarshalJSON

func (v ResponseURLs) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ResponseURLs) UnmarshalEasyJSON

func (v *ResponseURLs) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ResponseURLs) UnmarshalJSON

func (v *ResponseURLs) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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