Uploading image on open-file
benpixel opened this issue · 0 comments
benpixel commented
Hi, it's me again! :)
Do you have any experience with using open-file events? They're not really well documented. I've been trying to make something so I can have plugins in external applications send image to katana and the snippet below works but what happens when you try to do it once again after the app is running is that it will open a second instance of the app. There is some kind of a callback - makeSingleInstance, but I haven't really succeed in implementing.
electron.app.on('open-file', (e, path) => {
e.preventDefault()
electron.app.on('ready', () => {
const file = path
const ext = file.split('.').pop()
const allowed = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'tiff', 'pdf']
if (allowed.includes(ext)) {
this.screenshotModule.upload(file, (result, error) => {
if (!error) {
this.showNotification('Image has been successfully uploaded and copied to your clipboard', result.link)
} else {
this.showNotification(`Unable to upload screenshot ${error}`)
}
}, true)
}
})
})
Thanks,
Ben