Add GetFile API in app and plugin (#9820)
Этот коммит содержится в:
коммит произвёл
Hanzei
родитель
0541e765ad
Коммит
dbd3801271
@@ -336,6 +336,11 @@ type API interface {
|
||||
// Minimum server version: 5.3
|
||||
GetFileInfo(fileId string) (*model.FileInfo, *model.AppError)
|
||||
|
||||
// GetFile gets content of a file by it's ID
|
||||
//
|
||||
// Minimum Server version: 5.8
|
||||
GetFile(fileId string) ([]byte, *model.AppError)
|
||||
|
||||
// GetFileLink gets the public link to a file by fileId.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
|
||||
@@ -2837,6 +2837,35 @@ func (s *apiRPCServer) GetFileInfo(args *Z_GetFileInfoArgs, returns *Z_GetFileIn
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetFileArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
type Z_GetFileReturns struct {
|
||||
A []byte
|
||||
B *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetFile(fileId string) ([]byte, *model.AppError) {
|
||||
_args := &Z_GetFileArgs{fileId}
|
||||
_returns := &Z_GetFileReturns{}
|
||||
if err := g.client.Call("Plugin.GetFile", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetFile API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetFile(args *Z_GetFileArgs, returns *Z_GetFileReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetFile(fileId string) ([]byte, *model.AppError)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetFile(args.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetFile called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetFileLinkArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
@@ -713,6 +713,31 @@ func (_m *API) GetEmojiList(sortBy string, page int, perPage int) ([]*model.Emoj
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFile provides a mock function with given fields: fileId
|
||||
func (_m *API) GetFile(fileId string) ([]byte, *model.AppError) {
|
||||
ret := _m.Called(fileId)
|
||||
|
||||
var r0 []byte
|
||||
if rf, ok := ret.Get(0).(func(string) []byte); ok {
|
||||
r0 = rf(fileId)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]byte)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 *model.AppError
|
||||
if rf, ok := ret.Get(1).(func(string) *model.AppError); ok {
|
||||
r1 = rf(fileId)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetFileInfo provides a mock function with given fields: fileId
|
||||
func (_m *API) GetFileInfo(fileId string) (*model.FileInfo, *model.AppError) {
|
||||
ret := _m.Called(fileId)
|
||||
|
||||
Ссылка в новой задаче
Block a user