Spaces:
Sleeping
Sleeping
Upload 17 files
Browse files
server.js
CHANGED
|
@@ -71,10 +71,11 @@ app.get("/api/download", async (req, res) => {
|
|
| 71 |
});
|
| 72 |
|
| 73 |
app.post("/api/upload", upload.single("file"), async (req, res) => {
|
| 74 |
-
const { user_id, password
|
| 75 |
if (!req.file || !user_id || !password) {
|
| 76 |
return res.status(400).json({ error: "Missing file, user_id, or password" });
|
| 77 |
}
|
|
|
|
| 78 |
const fileData = {
|
| 79 |
data: [new Uint8Array(req.file.buffer)],
|
| 80 |
orig_name: req.file.originalname,
|
|
@@ -82,14 +83,13 @@ app.post("/api/upload", upload.single("file"), async (req, res) => {
|
|
| 82 |
mime_type: req.file.mimetype,
|
| 83 |
is_stream: false
|
| 84 |
};
|
| 85 |
-
const custom_name = req.file.originalname; // Required - use filename to avoid "blob"
|
| 86 |
try {
|
| 87 |
const client = await Client.connect("pockit-cloud/main", { hf_token: HF_TOKEN });
|
| 88 |
const result = await client.predict("/upload_file_secure", {
|
| 89 |
user_id,
|
| 90 |
password,
|
| 91 |
filepath: fileData,
|
| 92 |
-
custom_name
|
| 93 |
});
|
| 94 |
res.json({ data: result.data });
|
| 95 |
} catch (err) {
|
|
|
|
| 71 |
});
|
| 72 |
|
| 73 |
app.post("/api/upload", upload.single("file"), async (req, res) => {
|
| 74 |
+
const { user_id, password } = req.body;
|
| 75 |
if (!req.file || !user_id || !password) {
|
| 76 |
return res.status(400).json({ error: "Missing file, user_id, or password" });
|
| 77 |
}
|
| 78 |
+
const custom_name = req.file.originalname; // Required - use filename to avoid "blob"
|
| 79 |
const fileData = {
|
| 80 |
data: [new Uint8Array(req.file.buffer)],
|
| 81 |
orig_name: req.file.originalname,
|
|
|
|
| 83 |
mime_type: req.file.mimetype,
|
| 84 |
is_stream: false
|
| 85 |
};
|
|
|
|
| 86 |
try {
|
| 87 |
const client = await Client.connect("pockit-cloud/main", { hf_token: HF_TOKEN });
|
| 88 |
const result = await client.predict("/upload_file_secure", {
|
| 89 |
user_id,
|
| 90 |
password,
|
| 91 |
filepath: fileData,
|
| 92 |
+
custom_name
|
| 93 |
});
|
| 94 |
res.json({ data: result.data });
|
| 95 |
} catch (err) {
|