chore: auto-generate protobuf files [skip ci]
This commit is contained in:
308
gen/go/media/media.pb.go
Normal file
308
gen/go/media/media.pb.go
Normal file
@@ -0,0 +1,308 @@
|
|||||||
|
// contracts/proto/media/v1/media.proto
|
||||||
|
|
||||||
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-go v1.36.11
|
||||||
|
// protoc v4.25.9
|
||||||
|
// source: media/media.proto
|
||||||
|
|
||||||
|
package pb
|
||||||
|
|
||||||
|
import (
|
||||||
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
reflect "reflect"
|
||||||
|
sync "sync"
|
||||||
|
unsafe "unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||||
|
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||||
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
|
)
|
||||||
|
|
||||||
|
type UploadRequest struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
FileName string `protobuf:"bytes,1,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"`
|
||||||
|
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // Сами байты файла
|
||||||
|
Mode string `protobuf:"bytes,3,opt,name=mode,proto3" json:"mode,omitempty"` // "avatar", "chat", "raw"
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadRequest) Reset() {
|
||||||
|
*x = UploadRequest{}
|
||||||
|
mi := &file_media_media_proto_msgTypes[0]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadRequest) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*UploadRequest) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *UploadRequest) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_media_media_proto_msgTypes[0]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use UploadRequest.ProtoReflect.Descriptor instead.
|
||||||
|
func (*UploadRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return file_media_media_proto_rawDescGZIP(), []int{0}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadRequest) GetFileName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.FileName
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadRequest) GetData() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.Data
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadRequest) GetMode() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Mode
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadResponse struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
FileName string `protobuf:"bytes,1,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"`
|
||||||
|
Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadResponse) Reset() {
|
||||||
|
*x = UploadResponse{}
|
||||||
|
mi := &file_media_media_proto_msgTypes[1]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*UploadResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *UploadResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_media_media_proto_msgTypes[1]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use UploadResponse.ProtoReflect.Descriptor instead.
|
||||||
|
func (*UploadResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return file_media_media_proto_rawDescGZIP(), []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadResponse) GetFileName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.FileName
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *UploadResponse) GetSize() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Size
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPresignedUrlRequest struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
FileName string `protobuf:"bytes,1,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"`
|
||||||
|
IsPublic bool `protobuf:"varint,2,opt,name=is_public,json=isPublic,proto3" json:"is_public,omitempty"` // Если true, ссылка живет 24 часа, иначе 2 минуты
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlRequest) Reset() {
|
||||||
|
*x = GetPresignedUrlRequest{}
|
||||||
|
mi := &file_media_media_proto_msgTypes[2]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlRequest) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GetPresignedUrlRequest) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlRequest) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_media_media_proto_msgTypes[2]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use GetPresignedUrlRequest.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GetPresignedUrlRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return file_media_media_proto_rawDescGZIP(), []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlRequest) GetFileName() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.FileName
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlRequest) GetIsPublic() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.IsPublic
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPresignedUrlResponse struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlResponse) Reset() {
|
||||||
|
*x = GetPresignedUrlResponse{}
|
||||||
|
mi := &file_media_media_proto_msgTypes[3]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlResponse) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GetPresignedUrlResponse) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlResponse) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_media_media_proto_msgTypes[3]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use GetPresignedUrlResponse.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GetPresignedUrlResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return file_media_media_proto_rawDescGZIP(), []int{3}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetPresignedUrlResponse) GetUrl() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Url
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
var File_media_media_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
|
const file_media_media_proto_rawDesc = "" +
|
||||||
|
"\n" +
|
||||||
|
"\x11media/media.proto\x12\bmedia.v1\"T\n" +
|
||||||
|
"\rUploadRequest\x12\x1b\n" +
|
||||||
|
"\tfile_name\x18\x01 \x01(\tR\bfileName\x12\x12\n" +
|
||||||
|
"\x04data\x18\x02 \x01(\fR\x04data\x12\x12\n" +
|
||||||
|
"\x04mode\x18\x03 \x01(\tR\x04mode\"A\n" +
|
||||||
|
"\x0eUploadResponse\x12\x1b\n" +
|
||||||
|
"\tfile_name\x18\x01 \x01(\tR\bfileName\x12\x12\n" +
|
||||||
|
"\x04size\x18\x02 \x01(\x03R\x04size\"R\n" +
|
||||||
|
"\x16GetPresignedUrlRequest\x12\x1b\n" +
|
||||||
|
"\tfile_name\x18\x01 \x01(\tR\bfileName\x12\x1b\n" +
|
||||||
|
"\tis_public\x18\x02 \x01(\bR\bisPublic\"+\n" +
|
||||||
|
"\x17GetPresignedUrlResponse\x12\x10\n" +
|
||||||
|
"\x03url\x18\x01 \x01(\tR\x03url2\xa3\x01\n" +
|
||||||
|
"\fMediaService\x12;\n" +
|
||||||
|
"\x06Upload\x12\x17.media.v1.UploadRequest\x1a\x18.media.v1.UploadResponse\x12V\n" +
|
||||||
|
"\x0fGetPresignedUrl\x12 .media.v1.GetPresignedUrlRequest\x1a!.media.v1.GetPresignedUrlResponseB*Z(git.lendry.ru/lendry-erp/proto.git/go;pbb\x06proto3"
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_media_media_proto_rawDescOnce sync.Once
|
||||||
|
file_media_media_proto_rawDescData []byte
|
||||||
|
)
|
||||||
|
|
||||||
|
func file_media_media_proto_rawDescGZIP() []byte {
|
||||||
|
file_media_media_proto_rawDescOnce.Do(func() {
|
||||||
|
file_media_media_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_media_media_proto_rawDesc), len(file_media_media_proto_rawDesc)))
|
||||||
|
})
|
||||||
|
return file_media_media_proto_rawDescData
|
||||||
|
}
|
||||||
|
|
||||||
|
var file_media_media_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||||
|
var file_media_media_proto_goTypes = []any{
|
||||||
|
(*UploadRequest)(nil), // 0: media.v1.UploadRequest
|
||||||
|
(*UploadResponse)(nil), // 1: media.v1.UploadResponse
|
||||||
|
(*GetPresignedUrlRequest)(nil), // 2: media.v1.GetPresignedUrlRequest
|
||||||
|
(*GetPresignedUrlResponse)(nil), // 3: media.v1.GetPresignedUrlResponse
|
||||||
|
}
|
||||||
|
var file_media_media_proto_depIdxs = []int32{
|
||||||
|
0, // 0: media.v1.MediaService.Upload:input_type -> media.v1.UploadRequest
|
||||||
|
2, // 1: media.v1.MediaService.GetPresignedUrl:input_type -> media.v1.GetPresignedUrlRequest
|
||||||
|
1, // 2: media.v1.MediaService.Upload:output_type -> media.v1.UploadResponse
|
||||||
|
3, // 3: media.v1.MediaService.GetPresignedUrl:output_type -> media.v1.GetPresignedUrlResponse
|
||||||
|
2, // [2:4] is the sub-list for method output_type
|
||||||
|
0, // [0:2] is the sub-list for method input_type
|
||||||
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
|
0, // [0:0] is the sub-list for extension extendee
|
||||||
|
0, // [0:0] is the sub-list for field type_name
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { file_media_media_proto_init() }
|
||||||
|
func file_media_media_proto_init() {
|
||||||
|
if File_media_media_proto != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
type x struct{}
|
||||||
|
out := protoimpl.TypeBuilder{
|
||||||
|
File: protoimpl.DescBuilder{
|
||||||
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_media_media_proto_rawDesc), len(file_media_media_proto_rawDesc)),
|
||||||
|
NumEnums: 0,
|
||||||
|
NumMessages: 4,
|
||||||
|
NumExtensions: 0,
|
||||||
|
NumServices: 1,
|
||||||
|
},
|
||||||
|
GoTypes: file_media_media_proto_goTypes,
|
||||||
|
DependencyIndexes: file_media_media_proto_depIdxs,
|
||||||
|
MessageInfos: file_media_media_proto_msgTypes,
|
||||||
|
}.Build()
|
||||||
|
File_media_media_proto = out.File
|
||||||
|
file_media_media_proto_goTypes = nil
|
||||||
|
file_media_media_proto_depIdxs = nil
|
||||||
|
}
|
||||||
165
gen/go/media/media_grpc.pb.go
Normal file
165
gen/go/media/media_grpc.pb.go
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
// contracts/proto/media/v1/media.proto
|
||||||
|
|
||||||
|
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// - protoc-gen-go-grpc v1.6.1
|
||||||
|
// - protoc v4.25.9
|
||||||
|
// source: media/media.proto
|
||||||
|
|
||||||
|
package pb
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
grpc "google.golang.org/grpc"
|
||||||
|
codes "google.golang.org/grpc/codes"
|
||||||
|
status "google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the grpc package it is being compiled against.
|
||||||
|
// Requires gRPC-Go v1.64.0 or later.
|
||||||
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
|
const (
|
||||||
|
MediaService_Upload_FullMethodName = "/media.v1.MediaService/Upload"
|
||||||
|
MediaService_GetPresignedUrl_FullMethodName = "/media.v1.MediaService/GetPresignedUrl"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MediaServiceClient is the client API for MediaService service.
|
||||||
|
//
|
||||||
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||||
|
type MediaServiceClient interface {
|
||||||
|
// Загрузка файла
|
||||||
|
Upload(ctx context.Context, in *UploadRequest, opts ...grpc.CallOption) (*UploadResponse, error)
|
||||||
|
// Генерация временной ссылки для скачивания/просмотра
|
||||||
|
GetPresignedUrl(ctx context.Context, in *GetPresignedUrlRequest, opts ...grpc.CallOption) (*GetPresignedUrlResponse, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type mediaServiceClient struct {
|
||||||
|
cc grpc.ClientConnInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMediaServiceClient(cc grpc.ClientConnInterface) MediaServiceClient {
|
||||||
|
return &mediaServiceClient{cc}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *mediaServiceClient) Upload(ctx context.Context, in *UploadRequest, opts ...grpc.CallOption) (*UploadResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(UploadResponse)
|
||||||
|
err := c.cc.Invoke(ctx, MediaService_Upload_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *mediaServiceClient) GetPresignedUrl(ctx context.Context, in *GetPresignedUrlRequest, opts ...grpc.CallOption) (*GetPresignedUrlResponse, error) {
|
||||||
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
|
out := new(GetPresignedUrlResponse)
|
||||||
|
err := c.cc.Invoke(ctx, MediaService_GetPresignedUrl_FullMethodName, in, out, cOpts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MediaServiceServer is the server API for MediaService service.
|
||||||
|
// All implementations must embed UnimplementedMediaServiceServer
|
||||||
|
// for forward compatibility.
|
||||||
|
type MediaServiceServer interface {
|
||||||
|
// Загрузка файла
|
||||||
|
Upload(context.Context, *UploadRequest) (*UploadResponse, error)
|
||||||
|
// Генерация временной ссылки для скачивания/просмотра
|
||||||
|
GetPresignedUrl(context.Context, *GetPresignedUrlRequest) (*GetPresignedUrlResponse, error)
|
||||||
|
mustEmbedUnimplementedMediaServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnimplementedMediaServiceServer must be embedded to have
|
||||||
|
// forward compatible implementations.
|
||||||
|
//
|
||||||
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||||
|
// pointer dereference when methods are called.
|
||||||
|
type UnimplementedMediaServiceServer struct{}
|
||||||
|
|
||||||
|
func (UnimplementedMediaServiceServer) Upload(context.Context, *UploadRequest) (*UploadResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method Upload not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMediaServiceServer) GetPresignedUrl(context.Context, *GetPresignedUrlRequest) (*GetPresignedUrlResponse, error) {
|
||||||
|
return nil, status.Error(codes.Unimplemented, "method GetPresignedUrl not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedMediaServiceServer) mustEmbedUnimplementedMediaServiceServer() {}
|
||||||
|
func (UnimplementedMediaServiceServer) testEmbeddedByValue() {}
|
||||||
|
|
||||||
|
// UnsafeMediaServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
// Use of this interface is not recommended, as added methods to MediaServiceServer will
|
||||||
|
// result in compilation errors.
|
||||||
|
type UnsafeMediaServiceServer interface {
|
||||||
|
mustEmbedUnimplementedMediaServiceServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterMediaServiceServer(s grpc.ServiceRegistrar, srv MediaServiceServer) {
|
||||||
|
// If the following call panics, it indicates UnimplementedMediaServiceServer was
|
||||||
|
// embedded by pointer and is nil. This will cause panics if an
|
||||||
|
// unimplemented method is ever invoked, so we test this at initialization
|
||||||
|
// time to prevent it from happening at runtime later due to I/O.
|
||||||
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||||
|
t.testEmbeddedByValue()
|
||||||
|
}
|
||||||
|
s.RegisterService(&MediaService_ServiceDesc, srv)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _MediaService_Upload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(UploadRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MediaServiceServer).Upload(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: MediaService_Upload_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MediaServiceServer).Upload(ctx, req.(*UploadRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _MediaService_GetPresignedUrl_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetPresignedUrlRequest)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(MediaServiceServer).GetPresignedUrl(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: MediaService_GetPresignedUrl_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(MediaServiceServer).GetPresignedUrl(ctx, req.(*GetPresignedUrlRequest))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MediaService_ServiceDesc is the grpc.ServiceDesc for MediaService service.
|
||||||
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
var MediaService_ServiceDesc = grpc.ServiceDesc{
|
||||||
|
ServiceName: "media.v1.MediaService",
|
||||||
|
HandlerType: (*MediaServiceServer)(nil),
|
||||||
|
Methods: []grpc.MethodDesc{
|
||||||
|
{
|
||||||
|
MethodName: "Upload",
|
||||||
|
Handler: _MediaService_Upload_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetPresignedUrl",
|
||||||
|
Handler: _MediaService_GetPresignedUrl_Handler,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Streams: []grpc.StreamDesc{},
|
||||||
|
Metadata: "media/media.proto",
|
||||||
|
}
|
||||||
82
gen/media/media.ts
Normal file
82
gen/media/media.ts
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||||
|
// versions:
|
||||||
|
// protoc-gen-ts_proto v2.11.8
|
||||||
|
// protoc v4.25.9
|
||||||
|
// source: media/media.proto
|
||||||
|
|
||||||
|
/* eslint-disable */
|
||||||
|
import type { Metadata } from "@grpc/grpc-js";
|
||||||
|
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
||||||
|
import { Observable } from "rxjs";
|
||||||
|
|
||||||
|
export const protobufPackage = "media.v1";
|
||||||
|
|
||||||
|
/** contracts/proto/media/v1/media.proto */
|
||||||
|
|
||||||
|
export interface UploadRequest {
|
||||||
|
fileName: string;
|
||||||
|
/** Сами байты файла */
|
||||||
|
data: Uint8Array;
|
||||||
|
/** "avatar", "chat", "raw" */
|
||||||
|
mode: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UploadResponse {
|
||||||
|
fileName: string;
|
||||||
|
size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetPresignedUrlRequest {
|
||||||
|
fileName: string;
|
||||||
|
/** Если true, ссылка живет 24 часа, иначе 2 минуты */
|
||||||
|
isPublic: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetPresignedUrlResponse {
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MEDIA_V1_PACKAGE_NAME = "media.v1";
|
||||||
|
|
||||||
|
export interface MediaServiceClient {
|
||||||
|
/** Загрузка файла */
|
||||||
|
|
||||||
|
upload(request: UploadRequest, metadata?: Metadata): Observable<UploadResponse>;
|
||||||
|
|
||||||
|
/** Генерация временной ссылки для скачивания/просмотра */
|
||||||
|
|
||||||
|
getPresignedUrl(request: GetPresignedUrlRequest, metadata?: Metadata): Observable<GetPresignedUrlResponse>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MediaServiceController {
|
||||||
|
/** Загрузка файла */
|
||||||
|
|
||||||
|
upload(
|
||||||
|
request: UploadRequest,
|
||||||
|
metadata?: Metadata,
|
||||||
|
): Promise<UploadResponse> | Observable<UploadResponse> | UploadResponse;
|
||||||
|
|
||||||
|
/** Генерация временной ссылки для скачивания/просмотра */
|
||||||
|
|
||||||
|
getPresignedUrl(
|
||||||
|
request: GetPresignedUrlRequest,
|
||||||
|
metadata?: Metadata,
|
||||||
|
): Promise<GetPresignedUrlResponse> | Observable<GetPresignedUrlResponse> | GetPresignedUrlResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MediaServiceControllerMethods() {
|
||||||
|
return function (constructor: Function) {
|
||||||
|
const grpcMethods: string[] = ["upload", "getPresignedUrl"];
|
||||||
|
for (const method of grpcMethods) {
|
||||||
|
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
||||||
|
GrpcMethod("MediaService", method)(constructor.prototype[method], method, descriptor);
|
||||||
|
}
|
||||||
|
const grpcStreamMethods: string[] = [];
|
||||||
|
for (const method of grpcStreamMethods) {
|
||||||
|
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
||||||
|
GrpcStreamMethod("MediaService", method)(constructor.prototype[method], method, descriptor);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MEDIA_SERVICE_NAME = "MediaService";
|
||||||
Reference in New Issue
Block a user