This commit is contained in:
2026-04-16 17:21:48 +03:00
parent c8fa4c442d
commit c8e7e4e927
116 changed files with 3720 additions and 4197 deletions
+9 -9
View File
@@ -1,10 +1,10 @@
import { existsSync, createWriteStream, mkdirSync } from 'fs';
import { dirname } from 'path';
import axios from 'axios';
import { Logger } from '@nestjs/common';
import { existsSync, createWriteStream, mkdirSync } from "fs";
import { dirname } from "path";
import axios from "axios";
import { Logger } from "@nestjs/common";
export class ImageUtils {
private static readonly logger = new Logger('ImageUtils');
private static readonly logger = new Logger("ImageUtils");
/**
* Downloads an image from a URL and saves it to a local path.
@@ -26,8 +26,8 @@ export class ImageUtils {
// Download
const response = await axios({
url,
method: 'GET',
responseType: 'stream',
method: "GET",
responseType: "stream",
timeout: 5000,
validateStatus: (status) => status === 200, // Only save if 200 OK
});
@@ -37,8 +37,8 @@ export class ImageUtils {
response.data.pipe(writer);
return new Promise((resolve, reject) => {
writer.on('finish', () => resolve(true));
writer.on('error', (err) => {
writer.on("finish", () => resolve(true));
writer.on("error", (err) => {
this.logger.warn(
`Failed to write image to ${localPath}: ${err.message}`,
);