Upload PDF/DOC/XLSX/XLS/CSV/TXT/PNG/JPEG file formats in Netsuite File Cabinet

Apisero
3 min readJun 23, 2021

--

Author: Gajanan Karjalkar

In this blog, we will decipher how to upload the various types of file formats like pdf, doc, xlsx, xls, CSV, text, and some image file formats like png and jpeg Netsuite file Cabinet using Netsuite Add File connector.

You can take the file from your respective source system
For demo purpose, I’m taking the file from the local system

  1. Take the required file from the source system
    For example: pdf file

2.) Convert the payload toBase64 format

%dw 2.0

import * from dw::core::Binaries

output application/json

— -

toBase64(payload)

3.) Convert the base 64 value to binary

%dw 2.0

import * from dw::core::Binaries

output application/octet-stream

— -

fromBase64(payload as String) as Binary

4.) In the folder, id section mention the internal id of the folder in which you want to upload the file

%dw 2.0

output application/java

— -

{

internalId: 643

} as Object {

class : “com.mulesoft.connector.netsuite.extension.api.RecordRef”

}

To get the internal id of the folder right click on the specific folder in which you want to upload the file, then in the URL you will get the internal id of the folder.

5.) In the content section, you can mention payload, and in the file name, mention the name of the file along with its extension

6.) Convert the payload into JSON format

NOTE:- While uploading CSV file, make sure you convert it to proper base64 format, other steps remains the same as above

%dw 2.0

import * from dw::core::Binaries

output application/json

— -

toBase64((write(payload,”application/csv”)))

Similarly, you can upload different types of file formats.

--

--