Skip to content

fix: use Readable.from(buffer) for Google Drive upload#3

Open
samsulrifai wants to merge 1 commit into
zenhosta:mainfrom
samsulrifai:fix/upload-stream
Open

fix: use Readable.from(buffer) for Google Drive upload#3
samsulrifai wants to merge 1 commit into
zenhosta:mainfrom
samsulrifai:fix/upload-stream

Conversation

@samsulrifai

Copy link
Copy Markdown

Problem

Upload to Google Drive fails with part.body.pipe is not a function error.

This is caused by busboy v2 breaking changes where file (part) no longer exposes a standard Node.js readable stream directly as .body.

Solution

Buffer the incoming stream data first, then create a fresh Readable stream via Readable.from(fileBuffer) for the Google Drive upload API call.

Changes

  • Added import { Readable } from 'stream'
  • Collect stream chunks into a Buffer before uploading
  • Pass Readable.from(fileBuffer) to drive.files.create() instead of the raw busboy stream

Testing

  • Upload files via the web interface
  • Files now successfully upload to Google Drive

The original code passed busboy's file stream directly to
googleapis drive.files.create(), which caused 'part.body.pipe
is not a function' error due to busboy v2 breaking changes.

Now we buffer the stream data first, then create a fresh
Readable stream via Readable.from(fileBuffer) for the upload.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant