google-api-nodejs-client: Error when uploading Youtube video using Electron : Invalid multipart request with 0 mime parts.
This is related to https://github.com/googleapis/google-api-nodejs-client/issues/1083
It seems with the latest versions of googleapis the package switched from using axios to gaxios - this has caused this error to resurface when using the example code on an Electron app.
How should this be handled?
Environment details
- OS: osx
- Node.js version: v12.12.0
- npm version: 6.13.0
googleapis
version: “googleapis”: “^45.0.0”,
Steps to reproduce
- Use code from samples/youtube/upload.js inside Electron app
- Receive
Invalid multipart request with 0 mime parts.
error upon request
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 25 (11 by maintainers)
@JustinBeckwith Since gaxios is used for the requests, it would make sense to check for node/browser in the same way gaxios does (currently checks for
window.fetch
andwindow.URL
). If the body is a ReadStream it always can be executed as node since it doesnt work in the browser anyways.I guess the best course of action would be adding a execution environment setting to gaxios and using this to determine whether it should be executed as node/browser.
@sofisl How about inverting the assumption and changing the isBrowser function to a isNode function? In the sense of:
Or a explicit option to force node execution. It should at least throw some error if you try to stream a file through the browser.
Hi @Ribaas,
I think the best solution here is to either stream the video through the Node context, and not the browser context, as the library supports streaming only through the Node context. Alternatively, you could download the video to memory and then upload it to Youtube without using a stream. (As an aside, the nodejs-googleapis-common library was published today).
Beyond these two options, I think we’d be getting a bit too much into the Electron-specific realm, and you might want to open a bug with Electron referencing this issue.
Thanks!
Hey all. I was able to reproduce the issue successfully and found that, by changing
media
type tomultipart
, the file was uploaded successfully. Can you try that solution and see if it works for you? See code changed below: