MongoError: file with id xxx not opened for writing
See original GitHub issueMeteor-Files Version: 1.9.8
Meteor Version: 1.6.1
Issue appears on Desktop
Client or Server Issues: Server throws me a MongoError and on the client side throws me service unavailable. Server Error 503

Step to reproduce the problem:
// some test component.jsx
...
fetchImage = async _ => {
const response = await methodCall ( 'files.findOne', 'file-idxxx' );
this.setState. ( { src: Files.link ( response ) } );
}
render () {
const { src } = this.state;
return (
<div>
// click on this to simply get image link and view it, the response return just fine and i can successfully get the link, but after inject it into src, it throw me the MongoError
<button onClick={ this.fetchImage }>fetch</button>
<img src={ src } />
</div>
);
}
methods for the files.findOne
// methods.js
'files.findOne' ( _id ) {
// tried Files.findOne ( { _id } ) and throws me a Unhandled Promised Rejection error and maximum call stack exceed
return Files.collection.findOne ( { _id } );
}
methodCall.js
const methodCall = ( ...params ) => new Promise ( ( resolve, reject ) => {
const method = params [ 0 ];
store.dispatch ( methodRequest ( { method } ) );
Meteor.call ( ...params, ( error, response ) => {
if ( error ) {
store.dispatch ( methodFailure ( { method, error: error.reason } ) );
return reject ( error );
}
store.dispatch ( methodSuccess () );
return resolve ( response );
});
} );
Issue Analytics
- State:
- Created 6 years ago
- Comments:24 (11 by maintainers)
Top Results From Across the Web
MongoError: file with id ### not opened for writing #111 - GitHub
Need to store picture with my API using FeatherJS. I got the error MongoError: file with id ### not opened for writing. with...
Read more >What's Mongoose error Cast to ObjectId failed for value XXX at ...
Mongoose's findById method casts the id parameter to the type of the model's ... This is an ObjectId but "foo" is not a...
Read more >Unable to connect to Atlas cluster using "Standard ... - MongoDB
I am trying to connect to my Atlas cluster using “Standard Connection String” format. mongo "mongodb://xxx:xxx@xxx-shard-00-02.m32cu.mongodb.net ...
Read more >WiredTiger File Forensics Part 3: Viewing all the MongoDB Data
WiredTiger doesn't name any of its data files according to the MongoDB object names, so as a first step you'll have to extract...
Read more >MongoDB - Apache Camel
MongoDB is a very popular NoSQL solution and the camel-mongodb component integrates Camel with MongoDB allowing you to interact with MongoDB collections both...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@dr-dimitru I finally found the problem. It was a very very very silly mistake that I have made and cost me days of thinking of this.
After adding the
new Mongo.ObjectID, it gives clearer error message that the id was not exist, and the GridFS related issues u pointed me to #341, that it exist in mongo record does not mean it exist in FS. So I went to compare again against the wiki at theafterUploadhook and then saw the mistake.Thanks for your help and sorry for costing much of your time.
@dr-dimitru Yes, upload and view file without GridFS works fine.