randydev commited on
Commit
0753d74
·
verified ·
1 Parent(s): 8ce8afc

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +2 -1
index.js CHANGED
@@ -103,7 +103,8 @@ app.post("/api/v1/fluxai-ai", async (req, res) => {
103
  if (!imageBytes) {
104
  return res.status(500).json({ error: "Failed to fetch image bytes" });
105
  }
106
- const buffer = Buffer.from(await imageBytes.arrayBuffer());
 
107
  const processedImage = await sharp(buffer)
108
  .jpeg()
109
  .toBuffer();
 
103
  if (!imageBytes) {
104
  return res.status(500).json({ error: "Failed to fetch image bytes" });
105
  }
106
+ const buffer = Buffer.isBuffer(imageBytes) ? imageBytes : Buffer.from(imageBytes);
107
+
108
  const processedImage = await sharp(buffer)
109
  .jpeg()
110
  .toBuffer();