expire time settings #524
Unanswered
DeepVasoya08
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
is there any way to set expire time for any file like images? here is code i'm using but it is not working
`
conn.once("open", () => {
gfs = new mongoose.mongo.GridFSBucket(conn.db, {
bucketName: "stories",
});
});
const storage = new GridFsStorage({
url: process.env.MONGO_URL,
file: (req, file) => {
return new Promise((resolve, reject) => {
console.log(file);
const filename = file.originalname;
const fileInfo = {
filename: filename,
bucketName: "stories",
createdAt: { type: Date, expires: 20, default: Date.now },
};
resolve(fileInfo);
reject("server error!!");
});
},
options:
});
const upload = multer({ storage });`
Beta Was this translation helpful? Give feedback.
All reactions