Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterFilesServiceServer(s grpc1.Server, srv FilesServiceServer)
- type FileChunk
- func (*FileChunk) Descriptor() ([]byte, []int)
- func (m *FileChunk) GetData() []byte
- func (m *FileChunk) GetFileName() string
- func (m *FileChunk) Marshal() (dAtA []byte, err error)
- func (m *FileChunk) MarshalTo(dAtA []byte) (int, error)
- func (m *FileChunk) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*FileChunk) ProtoMessage()
- func (m *FileChunk) Reset()
- func (m *FileChunk) Size() (n int)
- func (m *FileChunk) String() string
- func (m *FileChunk) Unmarshal(dAtA []byte) error
- func (m *FileChunk) XXX_DiscardUnknown()
- func (m *FileChunk) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *FileChunk) XXX_Merge(src proto.Message)
- func (m *FileChunk) XXX_Size() int
- func (m *FileChunk) XXX_Unmarshal(b []byte) error
- type FilesServiceClient
- type FilesServiceServer
- type FilesService_GetFileClient
- type FilesService_GetFileServer
- type FilesService_UploadFileClient
- type FilesService_UploadFileServer
- type GetFileRequest
- func (*GetFileRequest) Descriptor() ([]byte, []int)
- func (m *GetFileRequest) GetFileName() string
- func (m *GetFileRequest) Marshal() (dAtA []byte, err error)
- func (m *GetFileRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *GetFileRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*GetFileRequest) ProtoMessage()
- func (m *GetFileRequest) Reset()
- func (m *GetFileRequest) Size() (n int)
- func (m *GetFileRequest) String() string
- func (m *GetFileRequest) Unmarshal(dAtA []byte) error
- func (m *GetFileRequest) XXX_DiscardUnknown()
- func (m *GetFileRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *GetFileRequest) XXX_Merge(src proto.Message)
- func (m *GetFileRequest) XXX_Size() int
- func (m *GetFileRequest) XXX_Unmarshal(b []byte) error
- type Handler
- type IPFSStorage
- type Server
- type Storage
- type UnimplementedFilesServiceServer
- type UploadFileResponse
- func (*UploadFileResponse) Descriptor() ([]byte, []int)
- func (m *UploadFileResponse) GetFileName() string
- func (m *UploadFileResponse) Marshal() (dAtA []byte, err error)
- func (m *UploadFileResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *UploadFileResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*UploadFileResponse) ProtoMessage()
- func (m *UploadFileResponse) Reset()
- func (m *UploadFileResponse) Size() (n int)
- func (m *UploadFileResponse) String() string
- func (m *UploadFileResponse) Unmarshal(dAtA []byte) error
- func (m *UploadFileResponse) XXX_DiscardUnknown()
- func (m *UploadFileResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *UploadFileResponse) XXX_Merge(src proto.Message)
- func (m *UploadFileResponse) XXX_Size() int
- func (m *UploadFileResponse) XXX_Unmarshal(b []byte) error
Constants ¶
const ( StorageTypeIPFS = "IPFS" EnvFileStorageBaseFolder = "FILE_STORAGE_BASE_FOLDER" EnvFileStorageType = "FILE_STORAGE_TYPE" EnvFileStorageIPFSEndpoint = "FILE_STORAGE_IPFS_ENDPOINT" )
Variables ¶
Functions ¶
func RegisterFilesServiceServer ¶
func RegisterFilesServiceServer(s grpc1.Server, srv FilesServiceServer)
Types ¶
type FileChunk ¶
type FileChunk struct { 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"` }
func (*FileChunk) Descriptor ¶
func (*FileChunk) GetFileName ¶
func (*FileChunk) MarshalToSizedBuffer ¶
func (*FileChunk) ProtoMessage ¶
func (*FileChunk) ProtoMessage()
func (*FileChunk) XXX_DiscardUnknown ¶
func (m *FileChunk) XXX_DiscardUnknown()
func (*FileChunk) XXX_Marshal ¶
func (*FileChunk) XXX_Unmarshal ¶
type FilesServiceClient ¶
type FilesServiceClient interface { // UploadFile allows to upload a file UploadFile(ctx context.Context, opts ...grpc.CallOption) (FilesService_UploadFileClient, error) // GetFile allows to get the contents of a file GetFile(ctx context.Context, in *GetFileRequest, opts ...grpc.CallOption) (FilesService_GetFileClient, error) }
FilesServiceClient is the client API for FilesService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewFilesServiceClient ¶
func NewFilesServiceClient(cc grpc1.ClientConn) FilesServiceClient
type FilesServiceServer ¶
type FilesServiceServer interface { // UploadFile allows to upload a file UploadFile(FilesService_UploadFileServer) error // GetFile allows to get the contents of a file GetFile(*GetFileRequest, FilesService_GetFileServer) error }
FilesServiceServer is the server API for FilesService service.
type FilesService_GetFileClient ¶
type FilesService_GetFileClient interface { Recv() (*FileChunk, error) grpc.ClientStream }
type FilesService_GetFileServer ¶
type FilesService_GetFileServer interface { Send(*FileChunk) error grpc.ServerStream }
type FilesService_UploadFileClient ¶
type FilesService_UploadFileClient interface { Send(*FileChunk) error CloseAndRecv() (*UploadFileResponse, error) grpc.ClientStream }
type FilesService_UploadFileServer ¶
type FilesService_UploadFileServer interface { SendAndClose(*UploadFileResponse) error Recv() (*FileChunk, error) grpc.ServerStream }
type GetFileRequest ¶
type GetFileRequest struct {
FileName string `protobuf:"bytes,1,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"`
}
func (*GetFileRequest) Descriptor ¶
func (*GetFileRequest) Descriptor() ([]byte, []int)
func (*GetFileRequest) GetFileName ¶
func (m *GetFileRequest) GetFileName() string
func (*GetFileRequest) Marshal ¶
func (m *GetFileRequest) Marshal() (dAtA []byte, err error)
func (*GetFileRequest) MarshalToSizedBuffer ¶
func (m *GetFileRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*GetFileRequest) ProtoMessage ¶
func (*GetFileRequest) ProtoMessage()
func (*GetFileRequest) Reset ¶
func (m *GetFileRequest) Reset()
func (*GetFileRequest) Size ¶
func (m *GetFileRequest) Size() (n int)
func (*GetFileRequest) String ¶
func (m *GetFileRequest) String() string
func (*GetFileRequest) Unmarshal ¶
func (m *GetFileRequest) Unmarshal(dAtA []byte) error
func (*GetFileRequest) XXX_DiscardUnknown ¶
func (m *GetFileRequest) XXX_DiscardUnknown()
func (*GetFileRequest) XXX_Marshal ¶
func (m *GetFileRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*GetFileRequest) XXX_Merge ¶
func (m *GetFileRequest) XXX_Merge(src proto.Message)
func (*GetFileRequest) XXX_Size ¶
func (m *GetFileRequest) XXX_Size() int
func (*GetFileRequest) XXX_Unmarshal ¶
func (m *GetFileRequest) XXX_Unmarshal(b []byte) error
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
NewHandler returns a new Handler instance
func NewHandlerFromEnvVariables ¶
func NewHandlerFromEnvVariables() *Handler
NewHandlerFromEnvVariables builds a new Handler instance reading the configurations from the environment variables
func (*Handler) GetFile ¶
GetFile gets the contents of the file having the given name, and writes them on a temporary file located at the returned path. Note: The caller should make sure the temporary file is deleted.
func (*Handler) SaveFile ¶
SaveFile reads the given request and stores the associated file bytes into a new file within the upload folder.
func (*Handler) UploadFile ¶
func (h *Handler) UploadFile(filePath string) (*UploadFileResponse, error)
UploadFile writes the contents of the file located at the given path in a temporary file, and uploads them remotely. After the uploads is completed, the path to the temporary file is returned along with the upload response. Note: The caller should make sure the temporary file is deleted.
type IPFSStorage ¶
type IPFSStorage struct {
// contains filtered or unexported fields
}
func NewIPFSStorage ¶
func NewIPFSStorage(ipfsEndpoint string) *IPFSStorage
func NewIPFStorageFromEnvVariables ¶
func NewIPFStorageFromEnvVariables() *IPFSStorage
func (*IPFSStorage) UploadFile ¶
func (s *IPFSStorage) UploadFile(filePath string) (string, error)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServerFromEnvVariables ¶
func NewServerFromEnvVariables() *Server
func (*Server) GetFile ¶
func (s *Server) GetFile(request *GetFileRequest, stream FilesService_GetFileServer) error
GetFile implements FilesServiceServer
func (*Server) UploadFile ¶
func (s *Server) UploadFile(stream FilesService_UploadFileServer) error
UploadFile implements FilesServiceServer
type Storage ¶
type Storage interface { // UploadFile uploads a file to the storage and returns the uploaded file name // that can be used to retrieve the file later on using the GetFile method. UploadFile(filePath string) (string, error) // GetFile returns the file associated with the given name GetFile(fileName string) ([]byte, error) }
func StorageFromEnvVariables ¶
func StorageFromEnvVariables() Storage
type UnimplementedFilesServiceServer ¶
type UnimplementedFilesServiceServer struct { }
UnimplementedFilesServiceServer can be embedded to have forward compatible implementations.
func (*UnimplementedFilesServiceServer) GetFile ¶
func (*UnimplementedFilesServiceServer) GetFile(req *GetFileRequest, srv FilesService_GetFileServer) error
func (*UnimplementedFilesServiceServer) UploadFile ¶
func (*UnimplementedFilesServiceServer) UploadFile(srv FilesService_UploadFileServer) error
type UploadFileResponse ¶
type UploadFileResponse struct {
FileName string `protobuf:"bytes,1,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"`
}
func NewUploadFileResponse ¶
func NewUploadFileResponse(fileName string) *UploadFileResponse
NewUploadFileResponse returns a new UploadFileResponse instance
func (*UploadFileResponse) Descriptor ¶
func (*UploadFileResponse) Descriptor() ([]byte, []int)
func (*UploadFileResponse) GetFileName ¶
func (m *UploadFileResponse) GetFileName() string
func (*UploadFileResponse) Marshal ¶
func (m *UploadFileResponse) Marshal() (dAtA []byte, err error)
func (*UploadFileResponse) MarshalTo ¶
func (m *UploadFileResponse) MarshalTo(dAtA []byte) (int, error)
func (*UploadFileResponse) MarshalToSizedBuffer ¶
func (m *UploadFileResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*UploadFileResponse) ProtoMessage ¶
func (*UploadFileResponse) ProtoMessage()
func (*UploadFileResponse) Reset ¶
func (m *UploadFileResponse) Reset()
func (*UploadFileResponse) Size ¶
func (m *UploadFileResponse) Size() (n int)
func (*UploadFileResponse) String ¶
func (m *UploadFileResponse) String() string
func (*UploadFileResponse) Unmarshal ¶
func (m *UploadFileResponse) Unmarshal(dAtA []byte) error
func (*UploadFileResponse) XXX_DiscardUnknown ¶
func (m *UploadFileResponse) XXX_DiscardUnknown()
func (*UploadFileResponse) XXX_Marshal ¶
func (m *UploadFileResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*UploadFileResponse) XXX_Merge ¶
func (m *UploadFileResponse) XXX_Merge(src proto.Message)
func (*UploadFileResponse) XXX_Size ¶
func (m *UploadFileResponse) XXX_Size() int
func (*UploadFileResponse) XXX_Unmarshal ¶
func (m *UploadFileResponse) XXX_Unmarshal(b []byte) error