node-wpapi icon indicating copy to clipboard operation
node-wpapi copied to clipboard

Unable to load media using path or buffer in electron app

Open cawa-93 opened this issue 5 years ago • 2 comments

Environment

  • electron: "9.1.0"
  • node: "12.14.1"
  • wpapi: "1.2.1"
  • Windows 10

I'm trying to execute the following code in the electron application in a dedicated worker.

const filePath = 'path/to/local/file' // or fs.readFile('path/to/file')
const media = await site.media().file(filePath).create({ post: wpPost.id });

Error:

TypeError: Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'.
    at Request../node_modules/superagent/lib/client.js.Request.attach (client.js:577)
    at Object._httpPost [as post] (http-transport.js:301)
    at EndpointRequest../node_modules/wpapi/lib/constructors/wp-request.js.WPRequest.create (wp-request.js:734)

cawa-93 avatar Jul 24 '20 14:07 cawa-93

Same error for me. but It's not Electron specific because I use React and got the same error

Cchumi avatar Nov 09 '20 17:11 Cchumi

Same error here. Any possible solution?

Tropicalista avatar Nov 19 '21 04:11 Tropicalista