mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-18 03:21:06 -05:00
41726949e8
Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: David Mehren <dmehren1@gmail.com>
24 lines
643 B
TypeScript
24 lines
643 B
TypeScript
import path from 'path'
|
|
import { URL } from 'url'
|
|
|
|
import { config } from '../../config'
|
|
import { logger } from '../../logger'
|
|
import { UploadProvider } from './index'
|
|
|
|
const FilesystemUploadProvider: UploadProvider = {
|
|
uploadImage: (imagePath, callback) => {
|
|
if (!callback || typeof callback !== 'function') {
|
|
logger.error('Callback has to be a function')
|
|
return
|
|
}
|
|
|
|
if (!imagePath) {
|
|
callback(new Error('Image path is missing or wrong'), undefined)
|
|
return
|
|
}
|
|
|
|
callback(undefined, (new URL(path.basename(imagePath), config.serverURL + '/uploads/')).href)
|
|
}
|
|
}
|
|
|
|
export { FilesystemUploadProvider }
|