summaryrefslogtreecommitdiffstats
path: root/plugin/hooks.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/hooks.go')
-rw-r--r--plugin/hooks.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/plugin/hooks.go b/plugin/hooks.go
index 5200291f2..944909077 100644
--- a/plugin/hooks.go
+++ b/plugin/hooks.go
@@ -4,6 +4,7 @@
package plugin
import (
+ "io"
"net/http"
"github.com/mattermost/mattermost-server/model"
@@ -28,6 +29,7 @@ const (
UserHasJoinedTeamId = 11
UserHasLeftTeamId = 12
ChannelHasBeenCreatedId = 13
+ FileWillBeUploadedId = 14
TotalHooksId = iota
)
@@ -113,4 +115,11 @@ type Hooks interface {
// UserHasLeftTeam is invoked after the membership has been removed from the database.
// If actor is not nil, the user was removed from the team by the actor.
UserHasLeftTeam(c *Context, teamMember *model.TeamMember, actor *model.User)
+
+ // FileWillBeUploaded is invoked when a file is uploaded, but before it is committed to backing store.
+ // Read from file to retrieve the body of the uploaded file. You may modify the body of the file by writing to output.
+ // Returned FileInfo will be used instead of input FileInfo. Return nil to reject the file upload and include a text reason as the second argument.
+ // Note that this method will be called for files uploaded by plugins, including the plugin that uploaded the post.
+ // FileInfo.Size will be automatically set properly if you modify the file.
+ FileWillBeUploaded(c *Context, info *model.FileInfo, file io.Reader, output io.Writer) (*model.FileInfo, string)
}