I am trying to use the TypeScript SDK to upload a connector file dependency (i.e. JDBC driver, etc.). I can easily do this with the Postman collection call, but for whatever reason, I keep getting either 400 or 500 errors whenever I try with the SDK. The SDK is supposed to build the FormData object for you, so I am just passing the file stream into the file parameter of the function. Any ideas? Here is my code:
//Upload connector files. connector_files is a CSV of the referenced JAR files
const connectorFiles = localSource.connectorAttributes.connector_files;
if (connectorFiles) {
const connectorFileList = connectorFiles.split(",");
for (const connectorFileName of connectorFileList) {
const relativeFilePath = `connectorLib/${connectorFileName}`;
winston.info(`Uploading connector library file [${relativeFilePath}]`);
let fullFilePath;
let fileStream;
try {
fileStream = fs.readFileSync(relativeFilePath);
fullFilePath = path.resolve(relativeFilePath);
winston.info(fullFilePath);
} catch (error) {
winston.error(`Could not find connector library dependency [${relativeFilePath}]. Put the file in the directory and try again`);
process.exit(1);
}
await sourcesApi.importConnectorFile({
sourceId: currentTartgetSource.id,
file: fileStream
});
}
}