Skip to content

Commit

Permalink
Merge pull request #710 from asmsuechan/fix-image-dropped
Browse files Browse the repository at this point in the history
Change to create a new directory when storage/images does not exist
  • Loading branch information
asmsuechan committed Jul 16, 2017
2 parents b21baf1 + bb9eb49 commit d0b835a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion browser/main/lib/dataApi/copyImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d0b835a

Please sign in to comment.