diff --git a/src/client.js b/src/client.js index 79731af6f..cf539bf7c 100644 --- a/src/client.js +++ b/src/client.js @@ -537,16 +537,18 @@ export class StreamChat { let fileField; const params = this._addClientParams(); - if (isReadableStream(uri) || uri instanceof File) { + const isFileWebAPI = input => + typeof window !== 'undefined' && 'File' in window && input instanceof File; + if (isReadableStream(uri) || isFileWebAPI(uri)) { fileField = uri; } else { fileField = { uri, name: name || uri.split('/').reverse()[0], }; - if (contentType != null) { - fileField.type = contentType; - } + } + if (contentType != null) { + fileField.type = contentType; } if (user != null) {