Add GetFileLink method to plugin API (#9665)
* add GetFileLink method to plugin API * Update plugin/api.go * add translations for new plugin API errors
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
db1123b8b2
Коммит
3bc89083fc
@@ -369,6 +369,23 @@ func (api *PluginAPI) GetFileInfo(fileId string) (*model.FileInfo, *model.AppErr
|
||||
return api.app.GetFileInfo(fileId)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetFileLink(fileId string) (string, *model.AppError) {
|
||||
if !api.app.Config().FileSettings.EnablePublicLink {
|
||||
return "", model.NewAppError("GetFileLink", "plugin_api.get_file_link.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
info, err := api.app.GetFileInfo(fileId)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if len(info.PostId) == 0 {
|
||||
return "", model.NewAppError("GetFileLink", "plugin_api.get_file_link.no_post.app_error", nil, "file_id="+info.Id, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return api.app.GeneratePublicLink(api.app.GetSiteURL(), info), nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) ReadFile(path string) ([]byte, *model.AppError) {
|
||||
return api.app.ReadFile(path)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user