I’m completely new to MongoDB, and I’m only working with it because I’m following a course on developing a microservices architecture.
For context, I have a db mp3s with collections fs.chunks and fs.files. I know there’s a file in it because when I run db.fs.files.find() I get:
[
{
_id: ObjectId('6848e8df124ab0ba0211ae4e'),
chunkSize: 261120,
length: Long('84261'),
uploadDate: ISODate('2025-06-11T02:24:31.416Z')
}
]
However, when I run the command mongofiles --db mp3s --prefix fs -l test.mp3 get_id 'ObjectId(""6848e8df124ab0ba0211ae4e"")', to the retrieve the file and name the output as test.mp3, I keep getting these logs
2025-06-13T22:45:06.590-0500 connected to: mongodb://localhost/
2025-06-13T22:45:06.608-0500 Failed: no such file with _id: ObjectId(6848e8df124ab0ba0211ae4e)
I know this is a pretty common question cus I’ve tried several methods in representing the ObjectId such as:
1) mongofiles --db mp3s --prefix fs -l test.mp3 get_id 'ObjectId("6848e8df124ab0ba0211ae4e")'
2) mongofiles --db mp3s --prefix fs -l test.mp3 get_id 'ObjectId(`"6848e8df124ab0ba0211ae4e`")'
3) mongofiles --db=mp3s --prefix=fs -l test.mp3 get_id '{ "_id": "ObjectId("6848e8df124ab0ba0211ae4e")"}'
4) mongofiles --db=mp3s --prefix=fs -l test.mp3 get_id '{ "$oid": "ObjectId("6848e8df124ab0ba0211ae4e")"}'
5) mongofiles --db=mp3s --prefix=fs -l test.mp3 get_id '{ "$id": "ObjectId("6848e8df124ab0ba0211ae4e")"}'
6) mongofiles --db=mp3s --prefix fs get_id --local=test.mp3 '{"_id": "6848e8df124ab0ba0211ae4e"}'
Literally fell asleep on my keyboard while trying different ways lol.
For further debugging purposes, I ran mongofiles --db=mp3s --prefix=fs list, and I can affirm the file is there because I’m getting
2025-06-14T10:49:27.023-0500 connected to: mongodb://localhost/
84261
I’m wondering if this is a case where mongofiles only acknowledges files with filenames, as mentioned in this previous post
NB. I started a similar discussion on Reddit, but unfortunately, I wasn’t getting anywhere