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

openDownloadStreamByName returns 0B file #5

Open
bondzi opened this issue Aug 9, 2022 · 1 comment
Open

openDownloadStreamByName returns 0B file #5

bondzi opened this issue Aug 9, 2022 · 1 comment

Comments

@bondzi
Copy link

bondzi commented Aug 9, 2022

I'm trying to migrate the large files from my MongoDB to S3 and found this script.

However, when I run it, I have issue with the following part.

function readFileFromMongo (file) { return gridFs.openDownloadStreamByName(file.filename) }

This openDownloadStreamByName (and also openDownloadStream), is returning the stream to me in the following format:

GridFSBucketReadStream
{ s: { bytesRead: 0, chunks: { s: {...} }, cursor: null, expected: 0, files: { s: {...} }, filter: { filename: "test_file.pdf", }, init: false, expectedEnd: 0, file: null, options: { sort: { uploadDate: -1, }, skip: null, start: undefined, end: undefined, }, readPreference: undefined, }, _readableState: { objectMode: false, highWaterMark: 16384, buffer: { head: null, tail: null, length: 0, }, length: 0, pipes: [ ], flowing: null, ended: false, endEmitted: false, reading: false, constructed: true, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: true, autoDestroy: true, destroyed: false, errored: null, closed: false, closeEmitted: false, defaultEncoding: "utf8", awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: false, decoder: null, encoding: null, }, _events: { }, _eventsCount: 0, _maxListeners: undefined, }

When I try to upload this file with s3.upload function, I get nothing, like it's not calling.

This are the params I'm passing to the upload function:
{ ACL: "public-read", Bucket: "migration-mongodb-documents-storage", Key: "test_file.pdf", Body: { s: { bytesRead: 0, chunks: { s: {...} }, cursor: null, expected: 0, files: { s: {...} }, filter: { filename: "test_file.pdf", }, init: false, expectedEnd: 0, file: null, options: { sort: { uploadDate: -1, }, skip: null, start: undefined, end: undefined, }, readPreference: undefined, }, _readableState: { objectMode: false, highWaterMark: 16384, buffer: { head: null, tail: null, length: 0, }, length: 0, pipes: [ ], flowing: null, ended: false, endEmitted: false, reading: false, constructed: true, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: true, autoDestroy: true, destroyed: false, errored: null, closed: false, closeEmitted: false, defaultEncoding: "utf8", awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: false, decoder: null, encoding: null, }, _events: { }, _eventsCount: 0, _maxListeners: undefined, }, ContentType: "binary/octet-stream", }

Am I doing something wrong?

@davimacedo
Copy link

What happens when you run the script? Would you mind to share the output?

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

No branches or pull requests

2 participants