SwiftcordApp / Swiftcord

A fully native Discord client for macOS built 100% in Swift!
https://swiftcordapp.github.io/Swiftcord/
GNU General Public License v3.0
1.85k stars 84 forks source link

[Bug]: Uploads above 8MB not accepted #151

Open BomberFish opened 1 year ago

BomberFish commented 1 year ago

Describe the Bug

Bug Description

Any file above 8 megabytes is not accepted. Recently, Discord changed the free file upload limit to 25 megabytes, and level 2 and 3 boosted servers increase the limit for all users to 50 and 100 megabytes respectively.

Actual Behaviour

The upload fails.

Screenshot taken on 2023-05-14 at 18 55 59

Expected Behavior

The upload should succeed.

Reproducing the Bug

  1. Upload file bigger than 8MB and less than 25MB on a nitroless account
  2. See it get denied :(

Version

0.6.1

Category

Media (images, audio, video etc.)

Relevant Log Output

No response

Screenshots

No response

Additional Info

No response

cryptoAlgorithm commented 1 year ago

Ah this is due to the file size limit being hardcoded in the upload check. It would simply require a single change here:

https://github.com/SwiftcordApp/Swiftcord/blob/89f48337cc2d46427b229e72bd050349183b9057/Swiftcord/Utils/Extensions/MessagesView%2B.swift#L107

Something along the lines of

- guard let size = try? attachment.resourceValues(forKeys: [URLResourceKey.fileSizeKey]).fileSize, size < 8*1024*1024 else { 
+ guard let size = try? attachment.resourceValues(forKeys: [URLResourceKey.fileSizeKey]).fileSize, size < 25*1024*1024 else {