Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a route for uploading avatars #4499

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add a route for uploading avatars #4499

wants to merge 1 commit into from

Conversation

nono
Copy link
Member

@nono nono commented Dec 10, 2024

No description provided.

@nono nono requested review from zatteo and Merkur39 December 10, 2024 11:21
@nono nono requested a review from a team as a code owner December 10, 2024 11:21
Copy link
Member

@taratatach taratatach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No risks of name collision in the afero version?

return &avatar{fs}
}

type avatar struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avatarFs seems more appropriate since this struct does not old data about avatars themselves but rather implements the interface allowing to manage them.

_ = u.fs.Remove(u.tmpname)
return err
}
return u.fs.Rename(u.tmpname, "avatar")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a constant storing the avatar filename would be nice

header := c.Request().Header
size := c.Request().ContentLength
if size > 20_000_000 {
return jsonapi.BadRequest(errors.New("Avatar is too big"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should return a 413 Entity Too Large error here.

}
header := c.Request().Header
size := c.Request().ContentLength
if size > 20_000_000 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have a MaxFileSize() method in the AvatarFS struct like the one in the Fs interface.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be an error returned by CreateAvatar()?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants