mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	Merge branch 'master' into next60
This commit is contained in:
		| @@ -20,6 +20,7 @@ const dayjs = require("dayjs"); | ||||
| const htmlSanitizer = require("./html_sanitizer"); | ||||
| const ValidationError = require("../errors/validation_error"); | ||||
| const noteTypesService = require("./note_types"); | ||||
| const fs = require("fs"); | ||||
|  | ||||
| /** @param {BNote} parentNote */ | ||||
| function getNewNotePosition(parentNote) { | ||||
| @@ -395,7 +396,24 @@ const imageUrlToAttachmentIdMapping = {}; | ||||
|  | ||||
| async function downloadImage(noteId, imageUrl) { | ||||
|     try { | ||||
|         const imageBuffer = await request.getImage(imageUrl); | ||||
|         let imageBuffer; | ||||
|  | ||||
|         if (imageUrl.toLowerCase().startsWith("file://")) { | ||||
|             imageBuffer = await new Promise((res, rej) => { | ||||
|                 const localFilePath = imageUrl.substr("file://".length); | ||||
|  | ||||
|                 return fs.readFile(localFilePath, (err, data) => { | ||||
|                     if (err) { | ||||
|                         rej(err); | ||||
|                     } else { | ||||
|                         res(data); | ||||
|                     } | ||||
|                 }); | ||||
|             }); | ||||
|         } else { | ||||
|             imageBuffer = await request.getImage(imageUrl); | ||||
|         } | ||||
|  | ||||
|         const parsedUrl = url.parse(imageUrl); | ||||
|         const title = path.basename(parsedUrl.pathname); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user