diff --git a/server/src/app.controller.ts b/server/src/app.controller.ts
index 524b5b6..1a4014d 100644
--- a/server/src/app.controller.ts
+++ b/server/src/app.controller.ts
@@ -21,6 +21,10 @@ interface Image {
headers?: { name: string; value: string }[];
}
+interface Video {
+ // Add properties for Video interface if needed
+}
+
@Controller('api')
export class AppController {
constructor(private readonly appService: AppService) {}
@@ -37,7 +41,7 @@ export class AppController {
) {
try {
const { images, format } = payload;
- console.log(images, format);
+ console.log("Received request with format:", format);
if (format !== 'original' && !this.isValidFormat(format)) {
throw new HttpException(
@@ -56,8 +60,9 @@ export class AppController {
const imageBuffer = Buffer.from(response.data);
if (format === 'original') {
- const contentType = response.headers['content-type'];
- zip.file(name, imageBuffer, { binary: true });
+ const contentType = response.headers['content-type'] as string;
+ console.log(`Adding original image: ${name}, type: ${contentType}`);
+ zip.file(name, imageBuffer, { binary: true, comment: contentType });
} else {
let sharpInstance = sharp(imageBuffer);
@@ -73,12 +78,14 @@ export class AppController {
}
const zipBuffer = await zip.generateAsync({ type: 'nodebuffer' });
+ console.log("ZIP file size:", zipBuffer.length);
reply
.header('Content-Type', 'application/zip')
.header('Content-Disposition', `attachment; filename=images.zip`)
.send(zipBuffer);
+ console.log("Response sent successfully");
return 'Images processed successfully';
} catch (error) {
console.error('Error processing images:', error);
@@ -91,7 +98,6 @@ export class AppController {
private isValidFormat(format: string): boolean {
const validFormats = [
- 'original',
'jpeg',
'png',
'webp',
@@ -130,4 +136,4 @@ export class AppController {
})
.run();
}
-}
+}
\ No newline at end of file
diff --git a/web/src/App.tsx b/web/src/App.tsx
index accde9e..7e5ab2b 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -1,36 +1,2 @@
-import { ImageStore } from "@/store/ImageStore";
-import "./App.css";
-import { Images } from "./components/images";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs";
-import { Videos } from "./components/videos";
-import { ImageDownload } from "./components/images/image-download";
-
-const App = () => {
- const { selectedImages } = ImageStore();
-
- return (
-
-
-
-
- Images
- Videos
-
-
-
- {selectedImages.length > 0 && (
-
-
-
- )}
-
-
-
-
-
-
-
- );
-};
-
-export default App;
+import { ImageStore } from "../../store/ImageStore";
+import { Button } from "../ui/button";
diff --git a/web/src/components/images/image-download.tsx b/web/src/components/images/image-download.tsx
index 04649c8..5391bda 100644
--- a/web/src/components/images/image-download.tsx
+++ b/web/src/components/images/image-download.tsx
@@ -18,6 +18,7 @@ export const ImageDownload: React.FC = () => {
const sendImages = async (images: Image[]): Promise => {
try {
+ console.log("Sending request with format:", format);
const response = await axios.post(
`https://downconvert-server.barron.agency/api/imgs`,
{
@@ -28,20 +29,29 @@ export const ImageDownload: React.FC = () => {
responseType: "blob",
}
);
- const contentdisposition =
- response.headers["content-disposition"].split("=")[1];
+
+ console.log("Response headers:", response.headers);
+ console.log("Response type:", response.data.type);
+
+ const contentDisposition = response.headers["content-disposition"];
+ const filename = contentDisposition
+ ? contentDisposition.split("filename=")[1].replace(/"/g, "")
+ : "images.zip";
+
const blob = new Blob([response.data], { type: "application/zip" });
- if (downloadLinkRef.current) {
- downloadLinkRef.current.href = URL.createObjectURL(blob);
- downloadLinkRef.current.download = contentdisposition;
- downloadLinkRef.current.click();
- URL.revokeObjectURL(downloadLinkRef.current.href);
- }
+ const url = window.URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = filename;
+ document.body.appendChild(a);
+ a.click();
+ window.URL.revokeObjectURL(url);
+ document.body.removeChild(a);
toast.success("Images downloaded successfully");
} catch (err) {
- console.error(err);
+ console.error("Error downloading images:", err);
toast.error("Error downloading images");
}
};