Uploading/POSTing a file to the File Cabinet from an outside web page

Hi all, I have an external application that is posting to a Suitelet and I’m attempting to create a new file in the file cabinet. I’m currently building a FormData object and delivering that with the POST. The FormData includes a file field and an input field.

Uploading/POSTing a file to the File Cabinet from an outside web page

My POST is hitting my Suitelet successfully and I’m able to extract and log the message field with the following:


But I can’t seem to figure out how to access the file from FormData. The following code:


Uploading/POSTing a file to the File Cabinet from an outside web page

Gives me [object FileList] but it doesn’t seem like I’m able to work with the object as expected – not even positive that it’s truly an object. Might just be a string.

I know I can create a Suitelet UI with a file input field and consume that pretty easily but I’m looking to use my external HTML page.

Does anyone know how to POST a file to the NetSuite backend and create a file (create.File) with it?

Thanks in advance!

Rookie Asked on February 5, 2021 in SuiteScript.
Add Comment
2 Answer(s)


This is definitely possible but I need to jog my memory. To start, could you JSON.strinfify() the FileList object and share the output.



Intermediate Answered on February 10, 2021.

Hey Chris, thanks for the response. When I stringified with my method above the result was “[object Filelist]”. I think that’s indicative that the files weren’t actually there, correct?

I’ve changed up my code a bit and now I’m just using a simple POST to a Suitelet via a form:

<form action={suitelet} method="POST" encType="multipart/form-data">
              <div className="site-card-border-less-wrapper">
                <Space direction="vertical" style={{ width: "100%" }}>
                  <TextArea name="message" rows="4" />
                  <input type="file" name="vanillaFile" />
                  <button type="submit">Submit</button>

The file field (vanillaFile) looks like this:


I feel like it’s not a good thing that the encoding/url/etc is coming back as null. I’m not sure if the file is even getting to NetSuite properly.

on February 11, 2021.
Add Comment

Assuming you are doing a simple form post using multipart form data, your file will be in the request: ServerRequest.files. You are supposed to set the folder and save it somewhere in the file cabinet

Advanced Answered on February 16, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor