I am getting attachment data from gmail API, they ...
# suitescript
r
I am getting attachment data from gmail API, they return it in base 64 string? It was originally a word file that is being converted to base 64? how do i recreated the file in netsuite file cabinet?
n
base 64 decode the string and then save?
r
Decode to what?
How
n
To the original binary content I guess?
Although, have you tried just saving it?
Thinking about it, I know in the past with image files I've been able to save the base64 string directly as the content and just specify the file type
r
Copy code
{
   type: "error.SuiteScriptError",
   name: "FAILED_TO_DECODE_STRING_ENCODED_BINARY_DATA_USING_1_ENCODING",
   message: "Failed to decode string-encoded binary data using 'BASE_64' encoding",
   stack: [
      "Error\n    at Object.map (/SuiteScripts/BFL_MR_TrackEmail.js:49:34)"
   ],
   cause: {
      type: "internal error",
      code: "FAILED_TO_DECODE_STRING_ENCODED_BINARY_DATA_USING_1_ENCODING",
      details: "Failed to decode string-encoded binary data using 'BASE_64' encoding",
      userEvent: null,
      stackTrace: [
         "Error\n    at Object.map (/SuiteScripts/BFL_MR_TrackEmail.js:49:34)"
      ],
      notifyOff: false
   },
   id: "",
   notifyOff: false,
   userFacing: true
}
this is the code
not working
n
did you try just setting the file content to be what you recieved without trying to decode it?
r
yes, but this is a word document type with an extension .docx, i do type = plaintext and put content , it does not work
do i put endoing too?
encoding?
n
You cannot use PLAINTEXT with a word document because it's not a plaintext document. NS does not support DOCX either you need to save it as .doc and the file.Type is "WORD"
r
trying
crossed fingers
message has been deleted
nothing
this gives a unexpected error
not even a suitescript error
n
have you got a try catch around the code and outputting any caught error? Could it be the folder you are writing to is not setup correctly?
r
I am in try catch
What do you mean by folder setup?
I just created a folder and took its internal id