Documentation ¶
Overview ¶
Package fileupload implements the functions, types, and interfaces for the module.
Package fileupload implements the functions, types, and interfaces for the module.
Index ¶
- Variables
- func GRPC2Header(header *fileuploadv1.FileHeader) fileupload.FileHeader
- func GenerateFileHash(filename string) string
- func GenerateHash(data string) string
- func GenerateRandomHash() string
- func Header2GRPCHeader(header fileupload.FileHeader) *fileuploadv1.FileHeader
- func NewBridgeUploader(builder *Builder, service fileupload.Uploader) fileupload.BridgeUploader
- func NewGRPCReceiver(stream grpc.ServerStream) fileupload.Receiver
- func NewGRPCUploader(ctx context.Context, service *configv1.Service) (fileupload.Uploader, error)
- func NewHTTPUploader(ctx context.Context, service *configv1.Service) (fileupload.Uploader, error)
- func ParseHeader(header fileupload.FileHeader) fileupload.FileInfo
- func ParseMultipart(header *multipart.FileHeader) fileupload.FileInfo
- type BridgeUploader
- type Builder
- func (b *Builder) Free(buf []byte)
- func (b *Builder) Init(ss ...BuilderSetting) *Builder
- func (b *Builder) NewBuffer() []byte
- func (b *Builder) NewReceiver(r *http.Request, w http.ResponseWriter) fileupload.Receiver
- func (b *Builder) NewUploader(ctx context.Context) fileupload.Uploader
- func (b *Builder) Timeout() time.Duration
- type BuilderSetting
- type FolderUploader
- type HTTPReceiver
- func (r *HTTPReceiver) Finalize(ctx context.Context, resp fileupload.UploadResponse) error
- func (r *HTTPReceiver) GetFileHeader(ctx context.Context) (fileupload.FileHeader, error)
- func (r *HTTPReceiver) GetOffset(ctx context.Context) (int64, error)
- func (r *HTTPReceiver) ReceiveFile(ctx context.Context) (io.ReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func GRPC2Header ¶
func GRPC2Header(header *fileuploadv1.FileHeader) fileupload.FileHeader
func GenerateFileHash ¶
func GenerateHash ¶
func GenerateRandomHash ¶
func GenerateRandomHash() string
func Header2GRPCHeader ¶
func Header2GRPCHeader(header fileupload.FileHeader) *fileuploadv1.FileHeader
func NewBridgeUploader ¶
func NewBridgeUploader(builder *Builder, service fileupload.Uploader) fileupload.BridgeUploader
NewBridgeUploader 创建一个新的桥接上传器
func NewGRPCReceiver ¶
func NewGRPCReceiver(stream grpc.ServerStream) fileupload.Receiver
func NewGRPCUploader ¶
func NewHTTPUploader ¶
func ParseHeader ¶
func ParseHeader(header fileupload.FileHeader) fileupload.FileInfo
func ParseMultipart ¶
func ParseMultipart(header *multipart.FileHeader) fileupload.FileInfo
Types ¶
type BridgeUploader ¶
type BridgeUploader struct { Builder *Builder Service fileupload.Uploader }
BridgeUploader 实现了HTTP到gRPC的桥接上传
func (*BridgeUploader) ServeHTTP ¶
func (b *BridgeUploader) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP 处理HTTP上传请求并转发到gRPC服务
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilder(ss ...BuilderSetting) *Builder
NewBuilder creates a new httpBuilder with the given options
func (*Builder) Init ¶
func (b *Builder) Init(ss ...BuilderSetting) *Builder
func (*Builder) NewReceiver ¶
func (b *Builder) NewReceiver(r *http.Request, w http.ResponseWriter) fileupload.Receiver
func (*Builder) NewUploader ¶
func (b *Builder) NewUploader(ctx context.Context) fileupload.Uploader
type BuilderSetting ¶
type BuilderSetting = func(builder *Builder)
func WithBufferSize ¶
func WithBufferSize(size int) BuilderSetting
func WithHash ¶
func WithHash(hash func(name string) string) BuilderSetting
func WithServiceType ¶
func WithServiceType(st fileupload.ServiceType) BuilderSetting
func WithTimeout ¶
func WithTimeout(timeout time.Duration) BuilderSetting
func WithURI ¶
func WithURI(uri string) BuilderSetting
type FolderUploader ¶
type FolderUploader struct {
// contains filtered or unexported fields
}
func NewFolderUploader ¶
func NewFolderUploader(builder Builder, basePath string) *FolderUploader
func (*FolderUploader) UploadFolder ¶
func (f *FolderUploader) UploadFolder(ctx context.Context, path string) error
type HTTPReceiver ¶
type HTTPReceiver struct {
// contains filtered or unexported fields
}
func (*HTTPReceiver) Finalize ¶
func (r *HTTPReceiver) Finalize(ctx context.Context, resp fileupload.UploadResponse) error
Finalize write the finalize status to the client and close the upload process.
func (*HTTPReceiver) GetFileHeader ¶
func (r *HTTPReceiver) GetFileHeader(ctx context.Context) (fileupload.FileHeader, error)
GetFileHeader read the file fileHeader from the request.
func (*HTTPReceiver) GetOffset ¶
func (r *HTTPReceiver) GetOffset(ctx context.Context) (int64, error)
func (*HTTPReceiver) ReceiveFile ¶
func (r *HTTPReceiver) ReceiveFile(ctx context.Context) (io.ReadCloser, error)
ReceiveFile read the file data to the server with path.
Click to show internal directories.
Click to hide internal directories.