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">
<head>
<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" />
</head>
<body>
<div><%- include('../partials/header.ejs')%></div>
<h2><%= formTitle%></h2>
<div class="RequestInfo">
<div>Destination Folder ID: <%= parentID%></div>
<div>Requestor ID: <%= requestorID%></div>
</div>
<form
method="post"
id="uploadForm"
action="<%= `http://localhost:8000/Zoho/WorkDrive/uploadFile?parentID=${parentID}&requestorID=${requestorID}` %>"
enctype="multipart/form-data"
>
<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"
/>
</form>
<%- include('../partials/footer.ejs')%>
</body>
</html>

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
*/

// PARSE:
// `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',
parentID,
requestorID,
})
})

Part 3 - Accept user upload response
// POST - uploadFile
router.post('/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(results)
// res.status(200).json({ fields, files });
})
.catch(err => {
console.error(err)
res.status(500).json(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
*/

// UTILS
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)
console.log(file)
console.log(process.env.ZOHO_accessToken_DELETETHIS)
// CREATE: axios instance
// const axios = getZohoAxios_WorkDrive.getZohoAxios_WorkDrive(ZOHO_ACCESS_TOKEN)
const axios = getZohoAxios_WorkDrive.getZohoAxios_WorkDrive(process.env.ZOHO_accessToken_DELETETHIS)
console.log(axios)

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

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

// EXPORTS
module.exports = uploadFile



        • Recent Topics

        • How does Zoho handle support operations for our EU users?

          Dear Zoho users, We have some news and reminders about how we handle support operations for Zoho users in the EU Data Center. This is part of our broader commitment to ensuring GDPR compliance and providing secure data handling for all users. We'd like
        • Layout Adjustment.

          Hello Latha, Hope you are doing well. I wanted to check with you about adjusting the layout columns in the Service Report from the backend, as currently there is no capability for us to customize the layout from our end. Below is the output that I am
        • Zoho Often Lag

          Desk Team, We've noticed that Desk, Creator & other apps seems to lag more these days. We often refresh multiple times.
        • Importing into the 'file upload' field

          Can you import attachments into the file upload field. I would expect it to work the same way as attachments do, But can't seem to get it to work. Moderation Update: The option to import into File Upload and Image Upload fields has been supported. Read
        • Layout Rules Don't Apply To Blueprints

          Hi Zoho the conditional layout rules for fields and making fields required don't work well with with Blueprints if those same fields are called DURING a Blueprint. Example. I have field A that is used in layout rule. If value of field A is "1" it is supposed to show and make required field B. If the value to field A is "2" it is supposed to show and make required field C. Now I have a Blueprint that says when last stage moves to "Closed," during the transition, the agent must fill out field A. Now
        • Zoho Desk blank screen

          opened a ticket from my email, zoho desk comes up blank, nothing loads. our receptionist also gets the same thing under her login on her computer. our sales rep also gets same thing on zoho desk at his home on a different computer. I tried clearing cache/history/cookies,
        • Optimum CRM setup for new B2B business

          Can some advise the most common way to setup Zoho CRM to handle sales for a B2B company? Specifically in how to handle inbound/outbound emails. I have spent hours researching online and can't seem to find an accepted approach, or even a tutorial. I have
        • filter on sheets mobile (iOS, iPadOS) does not work

          I have this issue on every spreadsheet, whether imported or created natively in Zoho Sheets. I can use on desktop without issue: desktop screenshot on iOS the filter dropdowns are not there and there is no way to add them mobile iPadOS looks the same
        • Is there a way to customize default settings?

          I want to customize default settings within my Zoho Business account. For instance, the current default setting for Texts inserted into a Notebook has the font much bigger than I like. Thus every time I create a new text item on a page, I have to go through the annoyance of selecting all the text and changing the size. Granted this is a minor irritation in the scheme of things, but it would be nice to have the ability to set default fonts, sizes, colors, background colors, etc. Is there currently
        • Can't edit Segments

          Happening with 2 different Zoho One environments, in different browsers. Please fix.
        • Error 554 Email Outgoing Error

          Our email address (info@tvbhouston) was recently migrated to a new domain host on WordPress, and our SSL certificate is still pending. We would like to continue using your service, but we are currently unable to send emails. Could you please re-enable
        • Transfer ownership of files and folders in My Folders

          People work together as a team to achieve organizational goals and objectives. In an organization, there may be situations when someone leaves unexpectedly or is no longer available. This can put their team in a difficult position, especially if there
        • Consumer Financing

          Does Zoho currently have a payment gateway (such as Stripe, Square, etc) which offers financing for customers? So, let's say the estimate we give the customer is greater than what they can afford at the time, but we can sell the service now, letting them
        • Subform edits don't appear in parent record timeline?

          Is it possible to have subform edits (like add row/delete row) appear in the Timeline for parent records? A user can edit a record, only edit the subform, and it doesn't appear in the timeline. Is there a workaround or way that we can show when a user
        • Zoho CRM - Option to create Follow-Up Task

          When completing a Zoho CRM Task, it would be very helpful if there was an option to "Complete and Create Follow-Up Task" in the pop-up which appears. It could clone the task you are closing and then show it on the screen in edit mode, all the user would
        • Deluge function to copy parent record file upload field to child record file upload field

          I'm stuck trying to write a deluge function that is triggered via automation in child record "Appointments," confirms if a file is in file upload "Report" field of parent "Contacts" record via Contacts lookup field "Contact_Name". If no file is in parent
        • Make panel configuration interface wider

          Hi there, The same way you changed the custom function editor's interface wider, it would be nice to be able to edit panels in pages using the full width of the screen rather than the currently max-width: 1368px. Is there a reason for having the configuration panel not taking the full width? Its impossible at this width to edit panels that have a lot of elements. Please change it to 100% so we can better edit the layouts. Thanks! B.
        • Image Compression Options

          Much better if we have level of options to compress the image [20%, 40%...] We are dealing with service reports daily that has before and after photos (image field)- the file size too large and one thing, the current limit is 10mb or 15mb for report
        • How to hide or archive a blog post temporarily in Zoho commerce website builder?

          I would like to temporarily hide or archive a blog post in zoho commerce website builder so that it doesnt appear on my website till I enable it again. I tried to look for this option but could not find it.  It only allows me to permanently delete a blog
        • How to mix different types of inputs (such as dropdown list and textbox)

          Hi, I'm creating a form called "Room Reservations" for a company. I created a "table" using "Matrix Choice". I created "Room 1", "Room 2" and "Room 3" with the "Questions". I would then like to create two columns with the "Answers", one called "Department"
        • Zoho Commerce - Poor Features Set for Blogging

          Hi Zoho Commerce team, I'm sure you will have noticed that I have been asking many questions about the Blogs feature in Commerce. I thought that it would be useful if I share my feedback in a constructive way, to highlight the areas which I feel need
        • Pass shipping info to payment gateway Zoho Books to Authorize.net

          For some reason the integration from Zoho books to Authorize.net does not pass the shipping address. Authorize.net is ready to receive it, but zoho books does not send it
        • Massive Zoho Books failure

          We have not received any communication or notification from Zoho, but we have detected that Zoho Books is not working for all our users. We cannot access or use Zoho Books. This is critical. We are trying to contact Zoho on the Spain telephone number,
        • Does the Customer “Company Name” field appear anywhere in the Zoho Books UI outside of PDFs?

          Hi everyone, I’m trying to understand how the Company Name field is actually used in Zoho Books. There is a Company Name field on the customer record, but when viewing transactions like a Sales Order in the normal UI (non-PDF view), that field doesn’t
        • Email outbox is now available in the sandbox

          Hello all! Testing emails without visibility has always been a blind spot in the sandbox. With the new Outbox, that gap is closed. You can now view and verify every email triggered from your sandbox, whether it’s through workflows, approvals, or mass
        • Looking For Recruit Developer

          Hi everyone, I am looking for a Zoho Certified Developer to assist with a development project for MetalXpert. We are building a software system designed to bridge the gap between a candidate mobile app and an employer web portal using Zoho Recruit as
        • sales IQ issue on website

          i integrated the zoho sales IQ code on the website but it is comming in distroted form i am sharing the screenshot below the website is bulit in wix platform
        • I need to know the IP address of ZOHO CRM.

          The link below is the IP address for Analytics, do you have CRM's? IP address for Analytics I would like to know the IP address of ZOHO CRM to allow communication as the API server I am developing is also run from CRM. Moderation Update: The post below
        • Important Update: Google Ads & YouTube Ads API Migration

          To maintain platform performance and align with Google's newest requirements, we are updating the Google Ads and YouTube Ads integrations by migrating from API v19 to the newer v22, before the official deprecation of v19 on February 11, 2026. Reference:
        • Blocklist candidates in Zoho Recruit

          We’re introducing Block Candidate, which helps recruiters to permanently restrict a candidate from applying to current/future job openings. Once the candidate is blocked, they will no longer be able to participate in the recruitment process. This will
        • Zoho Desk - Upsert Ticket

          Hi Desk Team, It is common to request more information from end-users. Using forms is a great way to ensure all the required information is collected. It would be great if there were an "upsert" option on the Zoho Form -> Zoho Desk integration which would
        • Client Side Scripts for Meetings Module

          Will zoho please add client side scripting support to the meetings module? Our workflow requires most meeting details have a specific format to work with other software we have. So we rely on a custom function to auto fill certain things. We currently
        • Introducing Multiple Sandbox Types and Support for Module's Data Population

          Register here for the upcoming Focus Group webinar on Multiple Sandbox | Help documentation to learn more about the new enhancements Hello everyone,  Sandbox in CRM is a testing environment for users to create and test new configurations like workflow
        • Creator Offline

          We had online access setup and working on our iphones. We have just set it up on an 'Android Tablet' and it is not downloading all the images? We use it to show customers our catalogue. Any ideas. Offline components all setup on both devices
        • Enable or disable any Field Rule!

          Hello Zoho Forms Community, We are excited to announce a powerful new enhancement to Field Rules that gives you greater control and flexibility in managing your form logic! Previously, if you wanted to temporarily deactivate a field rule, you had two
        • Marketing Tip #20: Increase traffic with strong meta titles and descriptions

          Meta titles and descriptions are what people see first on search results before they ever click through to your website. If your pages use generic titles or basic descriptions, you miss the chance to stand out, and search engines may not know which page
        • Kanban view on Zoho CRM mobile app!

          What is Kanban? The name doesn't sound English, right? Yes, Kanban is a Japanese word which means 'Card you can see'. As per the meaning, Kanban in CRM is a type of list view in which the records will be displayed in cards and categorized under the given
        • Not able to delete a QC nor able to revert or create a cycle of manufacturing for QC failed Jobs

          Not able to delete a QC nor able to revert or create a cycle of manufacturing for QC failed Jobs
        • Dheeraj Sudan and Meenu Hinduja-How do I customize Zoho apps to suit my needs?

          Hi Everyone, I'm Meenu Hinduja and my husband Dheeraj Sudan, run a business. I’m looking to tweak a few things to fit my needs, and I’d love to hear what customizations others have done. Any tips or examples would be super helpful! Regards Dheeraj Sudan
        • is there any way to change the "chat with us now" to custom message?

          is there any way to change the "chat with us now" to custom message? I want to change this text
        • Next Page