Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: local store fixed when trying to download pictures

Nevo David38b1cb2ce5b8
diff --git a/libraries/nestjs-libraries/src/upload/local.storage.ts b/libraries/nestjs-libraries/src/upload/local.storage.ts
index 87cf3cefa..3f6726257 100644
--- a/libraries/nestjs-libraries/src/upload/local.storage.ts
+++ b/libraries/nestjs-libraries/src/upload/local.storage.ts
@@ -3,16 +3,14 @@ import { mkdirSync, unlink, writeFileSync } from 'fs';
// @ts-ignore
import mime from 'mime';
import { extname } from 'path';
-import axios from 'axios';
-
export class LocalStorage implements IUploadProvider {
constructor(private uploadDirectory: string) {}
async uploadSimple(path: string) {
- const loadImage = await axios.get(path, { responseType: 'arraybuffer' });
+ const loadImage = await fetch(path);
const contentType =
- loadImage?.headers?.['content-type'] ||
- loadImage?.headers?.['Content-Type'];
+ loadImage?.headers?.get('content-type') ||
+ loadImage?.headers?.get('Content-Type');
const findExtension = mime.getExtension(contentType)!;
const now = new Date();
@@ -32,7 +30,7 @@ export class LocalStorage implements IUploadProvider {
const filePath = `${dir}/${randomName}.${findExtension}`;
const publicPath = `${innerPath}/${randomName}.${findExtension}`;
// Logic to save the file to the filesystem goes here
- writeFileSync(filePath, loadImage.data);
+ writeFileSync(filePath, Buffer.from(await loadImage.arrayBuffer()));
return process.env.FRONTEND_URL + '/uploads' + publicPath;
}