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

'Uncaught TypeError: Cannot read property 'indexOf' of undefined' when trying to upload a file #6813

Closed
martinvonwittich opened this issue Apr 26, 2017 · 4 comments

Comments

@martinvonwittich
Copy link

Rocket.Chat Version: 0.55.0-rc.6
Running Instances: 1
DB Replicaset OpLog: Disabled
Node Version: v4.5.0

Hi,

I just tried to upload a *.tar.gz file in the Ubuntu client:

  • I clicked on the "Attach file" button next to the text box where I can enter a chat message.
  • The file selector from my browser appears.
  • I double click a file.
  • The file selector closes, and nothing happens. The RocketChat dialog window "Do you want to upload a file?" just doesn't appear.

I can reproduce the issue on the web site, so this is probably not caused by the Ubuntu client.

Not all kinds of files are affected. Uploading "test.zip" file works fine:

martin@martin ~ % echo test > test
martin@martin ~ % zip test.zip test
updating: test (stored 0%)

Uploading "test" however does not.

The following exception is printed in the Chrome console when the upload fails:

caught TypeError: Cannot read property 'indexOf' of undefined
    at r (5b0b269….js?meteor_js_resource=true:260)
    at i (5b0b269….js?meteor_js_resource=true:260)
    at fileUpload (5b0b269….js?meteor_js_resource=true:260)
    at Object.change .message-form input[type=file] (5b0b269….js?meteor_js_resource=true:305)
    at 5b0b269….js?meteor_js_resource=true:130
    at Function.e._withTemplateInstanceFunc (5b0b269….js?meteor_js_resource=true:130)
    at h.View. (5b0b269….js?meteor_js_resource=true:130)
    at 5b0b269….js?meteor_js_resource=true:129
    at Object.h._withCurrentView (5b0b269….js?meteor_js_resource=true:129)
    at h._DOMRange. (5b0b269….js?meteor_js_resource=true:129)

The error seems to occur in this line:

return t.file.size > 1e7 ? e(t, null) : t.file.type.indexOf("audio") > -1 || t.file.type.indexOf("video") > -1 || t.file.type.indexOf("image") > -1 ? (t.type = t.file.type.split("/")[0],

I set Chrome to pause on exceptions, and examined t.file in the scope:

t: Object
  file: File
    lastModified: 1493237873201
    lastModifiedDate: Wed Apr 26 2017 22:17:53 GMT+0200 (CEST)
    name: "test"
    size: 5
    webkitRelativePath: ""
    type: undefined
    __proto__: File
@andreaazzara
Copy link

I can confirm this happens when uploading files with no extension

@Schobers
Copy link

Schobers commented May 9, 2017

Same error:
Client: Chrome 58.0.3029.96 (64-bit) on Windows
Server (on Ubuntu Core):

  • Version: 0.55.1
  • Node version: v4.8.0

Using a file with extension

@millerlucas
Copy link

Already fixed here : #6917

@Hudell
Copy link
Contributor

Hudell commented Jun 6, 2018

Closing this as it's already fixed.

@Hudell Hudell closed this as completed Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants