Writing Files to Tago


I am trying to write a text file to the Files area from an analysis. I can write a base64 file (as per a community post) but the uploadFile always generates an error.

Minimum code below to replicate issue:

Any ideas what I missed?

const {
} = require("@tago-io/sdk");

async function writeFileTest(context) {
const envVars = Utils.envToJson(context.environment);

const account = new Account({
token: envVars.account_token
const testBuffer = Buffer.from(“hello world”, “utf-8”);

const response = await account.files.uploadBase64([{
filename: “test1.txt”,
file: testBuffer.toString(“base64”),
contentType: “text/txt”,
public: true
}, ]);

const response2 = await account.files.uploadFile(
“text2.txt”, {
isPublic: true,
contentType: “text/txt”,
onProgress: () => {}


// To run analysis on your machine (external)
module.exports = new Analysis(writeFileTest, {
token: “xxxx”

throw new Error(Could not upload part number ${partNumber}: ${ex.message});

Error: Could not upload part number 1: undefined
at Files._addToQueue (…/Analysis/node_modules/@tago-io/sdk/out/modules/Account/Files.js:238:27)

Hi Gary,

It may be a problem on the SDK. It seems to be correct to me.

I will check internally and provide you an status on that.


Hi Gary,

That problem you’ve pointed out end up to be a bug. Good news is that our team has already fixed it. Your code is correct and should be working. (It has worked on a test I’ve performed)


Thanks for the quick patch Guilherme.
I’ll test it tomorrow

Hi Guilherme,

I tried this again after updating the node packages. This now works when running externally, but fails to create the test2.txt file when running on the internal the Tago IO Analysis screen. Was the fixed code pushed out to the production system?

Hi Gary,

sorry, its still not updated in production, I will keep you updated here but I dont promise anything before next week, we’re adding new features to analysis and that fix should be included on the next release.


No problem - we can run this externally for now.

1 Like