Skip to content

Commit

Permalink
fix: encoding (#1333)
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-dixit authored Feb 12, 2025
1 parent 1cea215 commit ef3f79b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions js/src/sdk/utils/fileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ export const saveFile = (
isTempFile: boolean = false
) => {
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const path = require("path");

Check warning on line 68 in js/src/sdk/utils/fileUtils.ts

View workflow job for this annotation

GitHub Actions / lint-and-prettify

A `require()` style import is forbidden
// eslint-disable-next-line @typescript-eslint/no-require-imports
const fs = require("fs");
const composioFilesDir = isTempFile
? getComposioTempFilesDir(true)
: getComposioDir(true);
const filePath = path.join(composioFilesDir, path.basename(file));
fs.writeFileSync(filePath, content);

if (Buffer.isBuffer(content)) {
fs.writeFileSync(filePath, content);
} else {
fs.writeFileSync(filePath, content, "utf8");
}

return filePath;
} catch (_error) {
Expand Down
5 changes: 3 additions & 2 deletions js/src/sdk/utils/processor/fileUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export const getFileDataAfterUploadingToS3 = async (
s3key: s3key,
};
};

export const downloadFileFromS3 = async ({
actionName,
s3Url,
Expand All @@ -114,7 +113,9 @@ export const downloadFileFromS3 = async ({
s3Url: string;
mimeType: string;
}) => {
const response = await axios.get(s3Url);
const response = await axios.get(s3Url, {
responseType: "arraybuffer",
});

const extension = mimeType.split("/")[1] || "txt";
const fileName = `${actionName}_${Date.now()}.${extension}`;
Expand Down

0 comments on commit ef3f79b

Please sign in to comment.