|
@@ -45,12 +45,17 @@ module.exports = async (dbName='snippet') => {
|
|
|
|
|
|
|
|
|
|
static async fromFileData(fileData){
|
|
static async fromFileData(fileData){
|
|
- let image = new Image({})
|
|
|
|
- image.fileData = fileData
|
|
|
|
- image.url = `images/${fileData.filename}`
|
|
|
|
- image.originalFileName = fileData.originalname
|
|
|
|
- await image.save()
|
|
|
|
- return image;
|
|
|
|
|
|
+ try {
|
|
|
|
+ let image = new Image({})
|
|
|
|
+ image.fileData = fileData
|
|
|
|
+ image.url = `images/${fileData.filename}`
|
|
|
|
+ image.originalFileName = fileData.originalname
|
|
|
|
+ await image.save()
|
|
|
|
+ return image;
|
|
|
|
+ }
|
|
|
|
+ catch(e){
|
|
|
|
+ console.log('wrong file')
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
static get relations(){
|
|
static get relations(){
|