TypeError: Cannot read property 'substring' of undefined
I've setup uppy-server for image uploading from google drive, dropbox &co, and is working great until the upload. I choose a file and click on "select", the thumbnails comes correctly up. But when I click on "Upload files" uppy-server quits with a TypeError.
::ffff:127.0.0.1 - "GET /drive/thumbnail/0B1zj7405adOCQzh0ZUhLYUw5eEk HTTP/1.0" 200 4500 "http://domain/index.php?sid=9bfc99e" "Mozilla/5.0"
::ffff:127.0.0.1 - "OPTIONS /drive/get/0B1zj7405adOCQzh0ZUhLYUw5eEk HTTP/1.0" 200 4 "-" "Mozilla/5.0"
uppy: [debug] debugLog Instantiating uploader.
uppy: [debug] uploader.validator.fail Invalid destination url
uppy: [debug] debugLog Waiting for socket connection before beginning remote download.
/usr/lib/node_modules/uppy-server/lib/server/Uploader.js:74
return this.token.substring(0, 8);
^
TypeError: Cannot read property 'substring' of undefined
at Uploader.get shortToken [as shortToken] (/usr/lib/node_modules/uppy-server/lib/server/Uploader.js:74:27)
at Uploader.onSocketReady (/usr/lib/node_modules/uppy-server/lib/server/Uploader.js:82:30)
at provider.size (/usr/lib/node_modules/uppy-server/lib/server/controllers/get.js:38:18)
at stats (/usr/lib/node_modules/uppy-server/lib/server/provider/drive.js:59:13)
at Request._callback (/usr/lib/node_modules/uppy-server/node_modules/purest/lib/transform.js:73:5)
at Request.self.callback (/usr/lib/node_modules/uppy-server/node_modules/request/request.js:186:22)
at Request.emit (events.js:182:13)
at Request.EventEmitter.emit (domain.js:442:20)
at Request.<anonymous> (/usr/lib/node_modules/uppy-server/node_modules/request/request.js:1163:10)
at Request.emit (events.js:182:13)
Solved. Uppy endpoint was not a absolute path.
@ifedapoolarewaju I wonder if we'd want to support relative paths? (not advocating or anything, honest question, it might be too magical and a source of more support tickets). And if we don't, if we should raise a clear error when a relative path is used?
I'm not sure what Uppy endpoint means in this case actually. Do we mean Uppy endpoint as in Upload target? Or endpoint as in uppy client? @gooof could you please clarify?
I meant the uppy client XHRUpload endpoint
wrong: Uppy.XHRUpload endpoint: '../upload.php?a=1&s=9bfc99e'
right: Uppy.XHRUpload endpoint: 'https://example.com/upload.php?a=1&s=9bfc99e'
var uppy = new Uppy.Core({
...
})
uppy.use(Uppy.Dashboard, { target: '.upload-area' })
uppy.use(Uppy.Dropbox, { target: Uppy.Dashboard, serverUrl: 'https://up.example.com' })
uppy.use(Uppy.GoogleDrive, { target: Uppy.Dashboard, serverUrl: 'https://up.example.com' })
uppy.use(Uppy.ProgressBar, { target: Uppy.Dashboard })
uppy.use(Uppy.XHRUpload, {
endpoint: '{UPLOAD_URL}',
getResponseError (responseText, xhr) { return new Error(JSON.parse(responseText).message) }
})
But I reopen this, because it is possible to break up "uppy server" remotely. That should be fixed.