aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-11-19 09:27:59 -0500
committerDrew DeVault <sir@cmpwn.com>2020-11-19 09:28:10 -0500
commit297afc5ce699823cca171aa0d44280e8b5e75b26 (patch)
tree7d38090b34edbed61bd07a6b2bcd947a8cec5689 /plugins/base
parent7b3e580fe4710b82cd8d971512ed4733a3909453 (diff)
downloadalps-297afc5ce699823cca171aa0d44280e8b5e75b26.tar.gz
alps-297afc5ce699823cca171aa0d44280e8b5e75b26.zip
Limit total size of unsent attachments
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/routes.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go
index c8d112e..3f379dd 100644
--- a/plugins/base/routes.go
+++ b/plugins/base/routes.go
@@ -692,7 +692,13 @@ func handleComposeAttachment(ctx *alps.Context) error {
var uuids []string
for _, fh := range form.File["attachments"] {
uuid, err := ctx.Session.PutAttachment(fh, form)
- if err != nil {
+ if err == alps.ErrAttachmentCacheSize {
+ form.RemoveAll()
+ return ctx.JSON(http.StatusBadRequest, map[string]string{
+ "error": "The total size of unset attachments on your session exceeds the maximum file size. Remove some attachments and try again.",
+ })
+ } else if err != nil {
+ form.RemoveAll()
ctx.Logger().Printf("PutAttachment: %v\n", err)
return ctx.JSON(http.StatusBadRequest, map[string]string{
"error": "failed to store attachment",