Companion GoogleDrive to XHRUpload

Hi guys, first of all thank you to the devs for this fantastic plugin!

I want the user to select an image from GDrive (already working), and have companion fetch the image and reupload it to my node express server as a multipart form (to an /api/drop/upload-photo endpoint).

I’v companion attached to my express app using these options:

const companionOptions = {
providerOptions: {
google: {
key: googleOauthKeys.key,
secret: googleOauthKeys.secret
}
},
server: {
host: ‘localhost:3000’,
protocol: ‘http’,
},
debug: true,
secret: “nevergonnagiveyouup”,
filePath: path.join(__dirname, ‘…/uploads’),
}

And uppy options on clientside:

uppy.use(Uppy.Dashboard, { trigger: ‘.open-uppy’ })
uppy.use(Uppy.GoogleDrive, { target: Uppy.Dashboard, companionUrl: http://localhost:3000’})
uppy.use(Uppy.XHRUpload, { endpoint: ‘/api/drop/upload-photo’, fieldName: ‘photo’ })

After selecting a file from GDrive, by clicking the Upload button on the dashboard I get these errors:
On the node app:
companion: 2019-09-26T17:12:32.963Z [debug] Instantiating uploader.
companion: 2019-09-26T17:12:32.967Z [debug] uploader.validator.fail No destination specified

On the client:
RequestClient.js:169 Uncaught (in promise) Error: Could not post http://localhost:3000/drive/get/1134trICiqhhISWCEpztmMRdW7AfYpOLh. Error: Failed request with status: 400. Bad Request

I’v tried debug the issue and created a simple middleware placed before uppy to log any request. Found that the request to companion has no body (empty object)

Before uppy, my app uses the middlewares:

app.use(express.static(“public”));
app.use(methodOverride("_method"));
app.use(methodOverride(“Access-Control-Allow-Methods”));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

I am using uppy in a demo app and not in production.
Thank you for your help!

Do you see any request body in the network tab in the browser console?

I wonder if the client is not sending any data, or if one of the middlewares is removing it.

@goto-bus-stop
I should have thought of that, thank you!
I found the problem:

Uppy was sending the json data as text/plain, so bodyParser was ignoring it.
By setting bodyparser options to: bodyParser.json({type: [‘application/json’,‘text/plain’]}), the body was received and parsed correctly.

Then I had another flat tire as my upload did not initiate because uppy was waiting on a websocket connection. I was not using websockets with the XHR Upload, but have now enabled it and the upload is fully functional. Docs aren’t clear about this being required.

Again, thank you for your help!