Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update file utilities for windows processing #1483

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update file utilities for improved processing
sjd9021 committed Mar 24, 2025
commit a0f3416cf6ce82116be5ae5f624aae34e9ef0e56
5 changes: 3 additions & 2 deletions js/src/sdk/utils/processor/fileUtils.ts
Original file line number Diff line number Diff line change
@@ -3,12 +3,13 @@
import crypto from "crypto";
import apiClient from "../../client/client";
import { saveFile } from "../fileUtils";
import pathModule from 'path';

const readFileContent = async (
path: string
): Promise<{ content: string; mimeType: string }> => {
try {
const content = require("fs").readFileSync(path);

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

GitHub Actions / lint-and-prettify

A `require()` style import is forbidden

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

GitHub Actions / lint-and-prettify

A `require()` style import is forbidden
return {
content: content.toString("base64"),
mimeType: "application/octet-stream",
@@ -102,9 +103,9 @@
fileData.mimeType,
client
);

return {
name: path.split("/").pop() || `${actionName}_${Date.now()}`,
name: pathModule.basename(path) || `${actionName}_${Date.now()}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment explaining the fallback filename pattern. Something like:

// Fallback to timestamp-based name if basename extraction fails
name: pathModule.basename(path) || `${actionName}_${Date.now()}`,

This would help future maintainers understand the purpose of the fallback.

mimetype: fileData.mimeType,
s3key: s3key,
};
Loading