diff --git a/lib/imageRouter/azure.ts b/lib/imageRouter/azure.ts index bc601659..1a2df524 100644 --- a/lib/imageRouter/azure.ts +++ b/lib/imageRouter/azure.ts @@ -6,7 +6,7 @@ import azure from "azure-storage"; import config from "../config"; import {logger} from "../logger"; -export function uploadImage(imagePath, callback) { +export function uploadImage(imagePath: string, callback?: (err: Error | null, url ?: string) => void): void { if (!imagePath || typeof imagePath !== 'string') { callback(new Error('Image path is missing or wrong'), null) return @@ -19,11 +19,11 @@ export function uploadImage(imagePath, callback) { const azureBlobService = azure.createBlobService(config.azure.connectionString) - azureBlobService.createContainerIfNotExists(config.azure.container, {publicAccessLevel: 'blob'}, function (err, result, response) { + azureBlobService.createContainerIfNotExists(config.azure.container, {publicAccessLevel: 'blob'}, function (err) { if (err) { callback(new Error(err.message), null) } else { - azureBlobService.createBlockBlobFromLocalFile(config.azure.container, path.basename(imagePath), imagePath, function (err, result, response) { + azureBlobService.createBlockBlobFromLocalFile(config.azure.container, path.basename(imagePath), imagePath, function (err, result) { if (err) { callback(new Error(err.message), null) } else { diff --git a/lib/imageRouter/filesystem.ts b/lib/imageRouter/filesystem.ts index c1a08183..5b5fffb7 100644 --- a/lib/imageRouter/filesystem.ts +++ b/lib/imageRouter/filesystem.ts @@ -34,7 +34,7 @@ function pickFilename(defaultFilename) { throw new Error('file exists.') } -export function uploadImage(imagePath, callback) { +export function uploadImage(imagePath: string, callback: (err: Error | null, url?: string) => void): void { if (!imagePath || typeof imagePath !== 'string') { callback(new Error('Image path is missing or wrong'), null) return diff --git a/lib/imageRouter/imgur.ts b/lib/imageRouter/imgur.ts index 58902bcf..dd85729f 100644 --- a/lib/imageRouter/imgur.ts +++ b/lib/imageRouter/imgur.ts @@ -4,7 +4,7 @@ import imgur from "@hackmd/imgur"; import config from "../config"; import {logger} from "../logger"; -export function uploadImage(imagePath, callback) { +export function uploadImage(imagePath: string, callback: (err: Error | null, url?: string) => void): void { if (!imagePath || typeof imagePath !== 'string') { callback(new Error('Image path is missing or wrong'), null) return diff --git a/lib/imageRouter/lutim.ts b/lib/imageRouter/lutim.ts index 67fa6214..4d4a385c 100644 --- a/lib/imageRouter/lutim.ts +++ b/lib/imageRouter/lutim.ts @@ -4,7 +4,7 @@ import config from "../config"; import {logger} from "../logger"; -export function uploadImage(imagePath, callback) { +export function uploadImage(imagePath: string, callback: (err: Error | null, url: string) => void): void { if (!imagePath || typeof imagePath !== 'string') { callback(new Error('Image path is missing or wrong'), null) return diff --git a/lib/imageRouter/minio.ts b/lib/imageRouter/minio.ts index f8c36ba8..f21e4f78 100644 --- a/lib/imageRouter/minio.ts +++ b/lib/imageRouter/minio.ts @@ -15,7 +15,7 @@ const minioClient = new Minio.Client({ secretKey: config.minio.secretKey }) -export function uploadImage(imagePath, callback) { +export function uploadImage(imagePath: string, callback: (err: Error | null, url?: string) => void): void { if (!imagePath || typeof imagePath !== 'string') { callback(new Error('Image path is missing or wrong'), null) return @@ -37,7 +37,7 @@ export function uploadImage(imagePath, callback) { minioClient.putObject(config.s3bucket, key, buffer, buffer.length, { ContentType: getImageMimeType(imagePath) - }, function (err, data) { + }, function (err) { if (err) { callback(err, null) return diff --git a/lib/imageRouter/s3.ts b/lib/imageRouter/s3.ts index 03ceea79..9de419a2 100644 --- a/lib/imageRouter/s3.ts +++ b/lib/imageRouter/s3.ts @@ -20,7 +20,7 @@ const s3 = new S3Client({ endpoint: config.s3.endpoint }) -export function uploadImage(imagePath, callback) { +export function uploadImage(imagePath: string, callback: (err: Error | null, url: string) => void): void { if (!imagePath || typeof imagePath !== 'string') { callback(new Error('Image path is missing or wrong'), null) return @@ -44,12 +44,12 @@ export function uploadImage(imagePath, callback) { } const mimeType = getImageMimeType(imagePath) if (mimeType) { - params.ContentType = mimeType + params.ContentType = mimeType as string } const command = new PutObjectCommand(params) - s3.send(command).then(data => { + s3.send(command).then(() => { let s3Endpoint = 's3.amazonaws.com' if (config.s3.endpoint) { s3Endpoint = config.s3.endpoint