mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
rework data function to provide filesize
This commit is contained in:
@@ -140,8 +140,9 @@ func (p *processor) UpdateAvatar(ctx context.Context, avatar *multipart.FileHead
|
||||
return nil, fmt.Errorf("UpdateAvatar: avatar with size %d exceeded max image size of %d bytes", avatar.Size, maxImageSize)
|
||||
}
|
||||
|
||||
dataFunc := func(ctx context.Context) (io.Reader, error) {
|
||||
return avatar.Open()
|
||||
dataFunc := func(ctx context.Context) (io.Reader, int, error) {
|
||||
f, err := avatar.Open()
|
||||
return f, int(avatar.Size), err
|
||||
}
|
||||
|
||||
isAvatar := true
|
||||
@@ -166,8 +167,9 @@ func (p *processor) UpdateHeader(ctx context.Context, header *multipart.FileHead
|
||||
return nil, fmt.Errorf("UpdateHeader: header with size %d exceeded max image size of %d bytes", header.Size, maxImageSize)
|
||||
}
|
||||
|
||||
dataFunc := func(ctx context.Context) (io.Reader, error) {
|
||||
return header.Open()
|
||||
dataFunc := func(ctx context.Context) (io.Reader, int, error) {
|
||||
f, err := header.Open()
|
||||
return f, int(header.Size), err
|
||||
}
|
||||
|
||||
isHeader := true
|
||||
|
@@ -36,8 +36,9 @@ func (p *processor) EmojiCreate(ctx context.Context, account *gtsmodel.Account,
|
||||
return nil, gtserror.NewErrorNotAuthorized(fmt.Errorf("user %s not an admin", user.ID), "user is not an admin")
|
||||
}
|
||||
|
||||
data := func(innerCtx context.Context) (io.Reader, error) {
|
||||
return form.Image.Open()
|
||||
data := func(innerCtx context.Context) (io.Reader, int, error) {
|
||||
f, err := form.Image.Open()
|
||||
return f, int(form.Image.Size), err
|
||||
}
|
||||
|
||||
emojiID, err := id.NewRandomULID()
|
||||
|
@@ -29,8 +29,9 @@ import (
|
||||
)
|
||||
|
||||
func (p *processor) Create(ctx context.Context, account *gtsmodel.Account, form *apimodel.AttachmentRequest) (*apimodel.Attachment, error) {
|
||||
data := func(innerCtx context.Context) (io.Reader, error) {
|
||||
return form.File.Open()
|
||||
data := func(innerCtx context.Context) (io.Reader, int, error) {
|
||||
f, err := form.File.Open()
|
||||
return f, int(form.File.Size), err
|
||||
}
|
||||
|
||||
focusX, focusY, err := parseFocus(form.Focus)
|
||||
|
Reference in New Issue
Block a user