WorkDrive API - upload file

WorkDrive API - upload file

Hello Zoho Community,

I am new to to Zoho one and currently working on a nodeJS / Express integration with WorkDrive.

I am able to successfully ping various routes for getting teams / users / files etc but I cannot get a file upload to work correctly. 

I think its coming down to the content param
- is the multipart the individual file type? 'application/pdf' etc
- what is the actual structure of the body object needed to represent the actual content being passed?

Can somebody see where I am going wrong??
Part 1 - Create EJS template w/ variables for dynamic route
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>McCormick Client Upload Portal</title>
<link rel="stylesheet" href="/styles/uploadPortal.css" />
<div><%- include('../partials/header.ejs')%></div>
<h2><%= formTitle%></h2>
<div class="RequestInfo">
<div>Destination Folder ID: <%= parentID%></div>
<div>Requestor ID: <%= requestorID%></div>
action="<%= `http://localhost:8000/Zoho/WorkDrive/uploadFile?parentID=${parentID}&requestorID=${requestorID}` %>"
<input type="file"
name="fileUploader" multiple
<input type="hidden"
id="parentID" name="parentID"
value="<%= parentID %>"
<input type="hidden"
id="requestorID" name="requestorID"
value="<%= requestorID %>"
<input type="submit"
name="submit" id="btnSubmit" value="Upload"
<%- include('../partials/footer.ejs')%>

Part 2 - Use route to prompt user to upload files w/ EJS template
// GET - upload portal URL
router.get('/uploadPortal', function(req,res) {
* We want to return the dynamic template with the following identifying information
* 1. 'parentID' => where is the file going in workdrive?
* 2. 'requestingID' => who is requesting the file

// `http://localhost:8000/Zoho/WorkDrive/uploadPortal?parentID=112233&requestorID=xxyyzz`
const parentID = req.query.parentID
// const parentID = '112233'
const requestorID = req.query.requestorID
// const requestorID = 'xxyyzz'

res.render(__dirname + '/views/uploadPortal', {
formTitle: 'McCormick Upload Portal',

Part 3 - Accept user upload response
// POST - uploadFile'/uploadFile', function(req,res) {
let uploadType = undefined
const form = formidable({ multiples: true });
form.parse(req, (err, fields, files) => {
// CHECK: error
if (err) {
res.status(500).json("Upload Error 1")
// next(err)
// return

console.log('FIELDS', fields)

// PARSE: query
const { parentID, requestorID } = req.query
console.log(typeof files.fileUploader)

// CONFIGURE: upload type
if (Array.isArray(files.fileUploader)) {
uploadType = 'multiple'
res.status(500).json({"Error": "functionality coming soon"})
} else if (typeof files.fileUploader === 'object') {
uploadType = 'single'
} else {
res.status(500).json({ "Error": "Parsed Files: Unknown input type"})

// USE MODEL: upload all files to workdrive
model_WorkDrive.uploadFiles(req.tokens[0], uploadType, files.fileUploader, parentID, requestorID)
.then(results => {
// res.status(200).json({ fields, files });
.catch(err => {

Part 3.5 - Shape of individual file
File {
  _events: [Object: null prototype] { error: [Function] },
  _eventsCount: 1,
  _maxListeners: undefined,
  size: 115540,
  path: '/var/folders/0k/t1ls81tn7sgby5p9zh5p68w40000gn/T/c07d33879b962b91c8b79ae00',
  name: 'Cover Letters 2.pdf',
  type: 'application/pdf',
  hash: null,
  lastModifiedDate: 2021-02-22T18:05:51.984Z,

Part 4 - Upload SINGLE file with WorkDrive API
* Desc:
* upload a single file to WorkDrive API
* Notes:
* this function will be used in a promise.all in order to faciliate
* uploading multiple files at once
* Args:
* parentID -- where to put the file
* requestorID -- which McCormick rep generated this upload request

const getZohoAxios_WorkDrive = require('../../../axiosService/utils/getZohoAxios')

const uploadFile = async (ZOHO_ACCESS_TOKEN, baseObj, file) => {
console.log('-- INSIDE UPLOAD FILE --')
console.log('BASE OBJ: ', baseObj)
// CREATE: axios instance
// const axios = getZohoAxios_WorkDrive.getZohoAxios_WorkDrive(ZOHO_ACCESS_TOKEN)
const axios = getZohoAxios_WorkDrive.getZohoAxios_WorkDrive(process.env.ZOHO_accessToken_DELETETHIS)

// PREP: queryParams
const params = `?filename=${}&parent_id=${baseObj.parent_id}&override-name-exist=${baseObj.overrideNameExist}&type=${file.type}`

// const result = await`/api/v1/upload${params}`, body)
const result = await`/api/v1/upload${params}`, {
"content": file
console.log('UPLOAD RESULT', result)

module.exports = uploadFile

            Zoho Marketing Automation
                    • Sticky Posts

                    • Ask the Experts 01 - A live Q&A on Zoho WorkDrive Features

                      Join the WorkDrive experts for our first ever "Ask The Experts" session! We are delighted to launch the first edition of our new "Ask the Experts" community series, conducted by our WorkDrive panelists. Our WorkDrive experts will be available to answer
                    • Welcome to the Zoho WorkDrive Community!

                      We're happy to announce Zoho WorkDrive Community, a platform for anyone to exchange ideas and best practices, ask questions, and connect with other users about how to use WorkDrive.  Our goal for this community is to make resources and help available to Zoho WorkDrive users. We'd love for you to use this forum to give us your feedback about the product, what has been working for you, and what can be improved.  Here are some of the ways you can have conversations, connect with each other, and learn

                    Zoho Pagesense Resources

                      Zoho SalesIQ Resources

                            Zoho TeamInbox Resources

                              Zoho DataPrep Resources

                                Zoho CRM Plus Resources

                                  Zoho Books Resources

                                    Zoho Subscriptions Resources

                                      Zoho Desk Resources

                                        Zoho Projects Resources

                                          Zoho Sprints Resources

                                            Qntrl Resources

                                              Zoho Creator Resources

                                                Zoho WorkDrive Resources

                                                    Zoho Campaigns Resources

                                                      Zoho CRM Resources

                                                            Design. Discuss. Deliver.

                                                            Create visually engaging stories with Zoho Show.

                                                            Get Started Now