Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

feat(ui): add max. file size check before upload attachment#2709

Merged
patak-dev merged 7 commits intomainfromuserquin/feat-prevent-file-upload
Apr 4, 2024

Conversation

userquin
Copy link
Member

@userquinuserquin commentedMar 21, 2024
edited
Loading

This PR prevents the file upload using themediaAttachments instance configuration:

  • videoSizeLimit for videos
  • imageSizeLimit for images

There are 2 more entriesimageMatrixLimit andvideoMatrixLimit, no idea if we should use them.

There is a problem with audio files, for example, webtoo.ls allowing audio files but there is noaudioSizeLimit inmediaAttachments options: should we use video or image? Right now using video size limit (we also need to include the audio message, this PR using the video message).

This PR also includes 2 new entries instate, using Intl.NumberFormat insideuseUploadMediaAttachment composable (composables/masto/publish.ts module):

  • attachments_limit_image_error
  • attachments_limit_video_error
  • attachments_limit_audio_error
  • attachments_limit_unknown_error

This PR includes translations for English (en.json), Spanish (es.json and es-419.json): also fixes an entry in es.json (video => vídeo). Messages are not reactive: if you go to the settings and change the locale the messages in the compose page will not be updated.

constnumber=123456.789;console.log(newIntl.NumberFormat('ar-EG',{style:'unit',unit:'megabyte',unitDisplay:"narrow",maximumFractionDigits:0}).format(number/(1024*1204),),);console.log(newIntl.NumberFormat('en-US',{style:'unit',unit:'megabyte',unitDisplay:"narrow",maximumFractionDigits:0}).format(number/(1024*1204),),);

/cc@mrcego

closes#1674

en.json

imagen

es.json

imagen

es-419.json

imagen

shuuji3, mrcego, and sapphi-red reacted with thumbs up emoji
@stackblitzStackBlitz
Copy link

Review PR in StackBlitz CodeflowRun & review this pull request inStackBlitz Codeflow.

@netlifyNetlify
Copy link

netlifybot commentedMar 21, 2024
edited
Loading

Deploy Preview forelk-docs canceled.

NameLink
🔨 Latest commit1da70aa
🔍 Latest deploy loghttps://app.netlify.com/sites/elk-docs/deploys/660dbb1070486d0008d2c553

@netlifyNetlify
Copy link

netlifybot commentedMar 21, 2024
edited
Loading

Deploy Preview forelk-zone ready!

NameLink
🔨 Latest commit1da70aa
🔍 Latest deploy loghttps://app.netlify.com/sites/elk-zone/deploys/660dbb0f186bb000085eea62
😎 Deploy Previewhttps://deploy-preview-2709--elk-zone.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to yourNetlify site configuration.

@userquin
Copy link
MemberAuthor

userquin commentedMar 21, 2024
edited
Loading

It seemswebtoo.ls getting wrong instance values, previous configuration entries allows uploading videos up to 40MB but that's not true, check linked issue (16MB).

imagen

@shuuji3
Copy link
Member

shuuji3 commentedMar 21, 2024
edited
Loading

I found this report on Mastodon repository:mastodon/mastodon#22757

I suspect 413 responses are raised due to the HTTP server application (or some kind of proxy?) setting, instead of Mastodon setting. It looks like if Mastodon checks the uploaded video, it will return 422 error when the size is exceeded.

If this assumption is correct, we will be able to upload 16MB video by adjusting the server configuration.

Either way, this new warning is a good addition.

Edit: this is the same advice to increaseclient_max_body_size for nginx users: Media upload errors with Mastodon instance - Opalstack Community Forum -https://community.opalstack.com/d/1078-media-upload-errors-with-mastodon-instance/11

@userquin
Copy link
MemberAuthor

userquin commentedMar 21, 2024
edited
Loading

@shuuji3 the problem is that masto api not throwing proper error and so we cannot access response status code, 413 should be used since it is the proper http response for it: entity too large iirc.

This PR should be ready, just added audio and unknown logic and messages.

shuuji3 reacted with thumbs up emoji

@userquinuserquin marked this pull request as ready for reviewMarch 21, 2024 16:41
@userquin
Copy link
MemberAuthor

userquin commentedMar 21, 2024
edited
Loading

should we usev2 api? this PR still using v1 in the create call

@userquin
Copy link
MemberAuthor

Intl.NumberFormat working also in FireFox, we need to test it in Safari:

imagen

@shuuji3
Copy link
Member

shuuji3 commentedMar 22, 2024
edited
Loading

checked quickly on Safari console (macOS) and it works as expected.
Screenshot 2024-03-22 at 12 24 27

This method is well supported now so it should be ok for all modern browsers:https://caniuse.com/?search=Intl.NumberFormat

should we usev2 api? this PR still using v1 in the create call

Does the masto.js interface has changed a lot? If we need to use the API differently, maybe it would be better to a separate PR to isolate the change. Otherwise, I think we can switch to v2.

@userquin
Copy link
MemberAuthor

The media v2 no, only the create method (now sent with a multipart form), maybe also the implementation the api is the same.

@userquin
Copy link
MemberAuthor

We alos need to handle kb, I'm going to move the logic to i18n composable.

shuuji3 reacted with thumbs up emoji

@userquin
Copy link
MemberAuthor

This method is well supported now so it should be ok for all modern browsers:https://caniuse.com/?search=Intl.NumberFormat

Nice

@shuuji3
Copy link
Member

There are 2 more entriesimageMatrixLimit andvideoMatrixLimit, no idea if we should use them.

TheimageMatrixLimit is the number of pixels in an image and m.webtoo.ls has the limit of16777216. I thought the image with more than this pixel could not be loaded, but the larger image was resized on the server side. So I think we don't have to use this number to check the image resolution on the client side.

I tried uploading 10,000x10,000px png image (exceeding16777216) but it was successfully uploaded and resized to 1,440x1,440px by Mastodon server.
Screenshot from 2024-03-25 13-09-01

Copy link
Member

@shuuji3shuuji3 left a comment

Choose a reason for hiding this comment

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

I tested large audio files (90MB and 100MB) on mastodon.social, which configured 100MB as the video size limitation. I couldn't find the audio specific size limitation but the limitation is virtually the same as the video size limitation (<100MB). So it's reasonable to assume the limit of the audio size is the same as video.

userquinand others added2 commitsApril 3, 2024 22:12
Co-authored-by: TAKAHASHI Shuuji <shuuji3@gmail.com>
Copy link
Member

@shuuji3shuuji3 left a comment

Choose a reason for hiding this comment

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

Thanks

@patak-devpatak-dev added this pull request to themerge queueApr 4, 2024
Merged via the queue intomain with commit3f0b234Apr 4, 2024
15 checks passed
@patak-devpatak-dev deleted the userquin/feat-prevent-file-upload branchApril 4, 2024 10:30
maybeanerd pushed a commit to maybeanerd/crab that referenced this pull requestApr 6, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@shuuji3shuuji3shuuji3 approved these changes

@patak-devpatak-devAwaiting requested review from patak-dev

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Video upload error
3 participants
@userquin@shuuji3@patak-dev

[8]ページ先頭

©2009-2025 Movatter.jp