File instance codes:
const fileType = req.file.mimetype;
const value = fileType.substring(fileType.lastIndexOf(ā/ā) + 1);
const imageFile = new Moralis.File(myNFT.${value}
, {base64 : btoa(JSON.stringify(file))});
await imageFile.saveIPFS({useMasterKey: true});
imageURI = imageFile.ipfs();
Multer codes:
let storage = multer.memoryStorage({
destination: (req, file, cb) => cb(null, āuploads/ā),
})
let upload = multer({
storage: storage,
fileFilter: (req, file, cb) => {
if (file.mimetype == āimage/pngā || file.mimetype == āimage/jpgā || file.mimetype == āimage/jpegā) {
cb(null, true);
} else {
cb(null, false);
return cb(new ApiError(4002, āOnly .png, .jpg and .jpeg format allowed!ā));
}
},
limits: {
fileSize: 1024 * 1024 * 1
},
}).single(āimageā);
Also have tried without the multer local storage. Not getting the solve yet. Maybe there is the problem with this line only: āconst imageFile = new Moralis.File(myNft.${value}
, {base64 : btoa(JSON.stringify(file))});ā