mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-12 03:33:58 -05:00
7b9f9a487b
Signed-off-by: David Mehren <git@herrmehren.de>
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 }
|