Skip to content

openDownloadStreamByName returns 0B file #5

@bondzi

Description

@bondzi

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions