1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Merge pull request #710 from asmsuechan/fix-image-dropped

Change to create a new directory when storage/images does not exist
This commit is contained in:
SuenagaRyota
2017-07-16 15:52:03 +09:00
committed by GitHub

View File

@@ -22,7 +22,9 @@ function copyImage (filePath, storageKey) {
const imageExt = path.extname(filePath)
const imageName = Math.random().toString(36).slice(-16)
const basename = `${imageName}${imageExt}`
const outputImage = fs.createWriteStream(path.join(targetStorage.path, 'images', basename))
const imageDir = path.join(targetStorage.path, 'images')
if (!fs.existsSync(imageDir)) fs.mkdirSync(imageDir)
const outputImage = fs.createWriteStream(path.join(imageDir, basename))
inputImage.pipe(outputImage)
resolve(`${targetStorage.path}/images/${basename}`)
} catch (e) {