GetStream / stream-chat-react

React Chat SDK ➜ Stream Chat 💬
https://getstream.io/chat/sdk/react/
Other
698 stars 272 forks source link

bug: no way to disable file upload limit of 100mb when using our own upload process? #2473

Open MatheoJaouen opened 4 weeks ago

MatheoJaouen commented 4 weeks ago

Describe the bug

A clear and concise description of what the bug is.

No way to disable size limit when using our own uploader? Trying in the app config to setup it too, still limited to 100mb image image related RN ticket, https://github.com/GetStream/stream-chat-react-native/issues/2617

I would prefer not to update the config either, adding an extra call at app launch etc. https://getstream.io/chat/docs/react/app_setting_overview/#file-uploads await client.updateAppSettings({

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A way to completely disable the file size limit when using our own uploader.

A clear and concise description of what you expected to happen.

Screenshots image

If applicable, add screenshots to help explain your problem.

Package version

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

Add any other context about the problem here.

MartinCupela commented 3 weeks ago

Hey @MatheoJaouen , you are probably using a function that uploads to the Stream's server right? Maybe you could perform the upload call with to your servers and then use the upsertAttachments function that can be accessed as follows:

const {upsertAttachment} = useMessageInputContext();

The function is not documented for v11 as it is officially presented in the v12 documentation. For v12 there are rc versions available (latest here).

MatheoJaouen commented 3 weeks ago

We upload everything to our own servers, we use our own uppy instance to our servers.

We pass a custom Input where we handle our custom upload then we use regular functions from hooks etc,

        <MessageInput<LandrChatGenerics>
            overrideSubmitHandler={overrideSubmitHandler}
            Input={MessageInputUI}

const messageInputContext = useMessageInputContext<LandrChatGenerics>();
            messageInputContext.fileOrder,
            messageInputContext.imageOrder,
            messageInputContext.text,
            messageInputContext.numberOfUploads,
            messageInputContext.handleChange,
            messageInputContext.handleSubmit,
            messageInputContext.uploadNewFiles,

The "bug" must have appear after a bump or if a default limit was set on your side?

The check is done here, which is used in useAttachment etc which is apparently core feature (then used for a lot of different stuff, upload preview etc etc etc). https://github.com/GetStream/stream-chat-react/blob/efbc08da0391845914e745bcdf0f8f32b7bc0869/src/components/MessageInput/hooks/utils.ts#L195

It would be better to have the possibility to disabled completely any limitation (files etc) from the dashboard directly or from the code when we use our own upload check/servers.

I did a patch meanwhile on the file to comment the checks but I'm sure others will face the same issue.

MartinCupela commented 3 weeks ago

Have you tried v12?

MatheoJaouen commented 3 weeks ago

Not yet (patch is so far easier than refactoring), But even if it does not go through the check it would be better to remove your default limits form the dashboard. Specifying GS servers only accepts file up to 100MB but let go other values

(I won't be able to reply before a week if ever)

MartinCupela commented 2 weeks ago

Hey @MatheoJaouen, you are running into this issue because of pervasive use of uploadNewFiles function that allows to upload only to Stream's infrastructure. It is then natural to check the file size limit, but it also forces you to override all the components that can possibly upload the files. We will change this so that you can override the uploadNewFiles function over MessageInput props without having to override all the components that use this function.