Skip to content

Conversation

@javorosas
Copy link
Member

  • Now using isomorphic formdata-node package
  • Convert NodeJS.ReadableStreams to Buffer to make it compatible with fetch

@javorosas javorosas added the bug label Apr 23, 2025
@javorosas javorosas self-assigned this Apr 23, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses file upload issues across different environments by replacing the usage of the form-data package with the isomorphic formdata-node package and converting NodeJS.ReadableStreams to Buffers to ensure compatibility with fetch.

  • Removed the form-data module from the external dependencies in the Vite configuration.
  • Refactored wrapper and organizations code to use FormData uniformly, along with adding a utility (streamToBuffer) for Node stream conversion.
  • Updated the CHANGELOG to document these file upload improvements.

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
vite.config.ts Removed 'form-data' from external dependencies to align with the new isomorphic formdata-node usage.
src/wrapper.ts Refactored FormData usage and header handling to support both Node and browser environments.
src/utils/streamToBuffer.ts Added a utility function to convert NodeJS.ReadableStream objects to Buffers.
src/resources/organizations.ts Updated file upload methods to support Buffer and ReadableStream inputs using the prepareFile utility.
CHANGELOG.md Documented the updated file upload methods and related fixes.
Files not reviewed (1)
  • package.json: Language not supported
Comments suppressed due to low confidence (1)

src/wrapper.ts:99

  • By removing the custom header logic that incorporated formData boundary details in Node environments, there is a risk that the request may lack the necessary 'Content-Type' boundary parameters. Consider verifying if the new header logic works correctly with formdata-node on the server side.
headers: { ...defaultHeaders, ...(formData ? {} : { 'Content-Type': 'application/json' }), }

@javorosas javorosas merged commit 03ea457 into main Apr 23, 2025
@javorosas javorosas deleted the FAC-1317/fix/file-upload branch April 23, 2025 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants