Merge pull request 'Mobile upload image' (#4) from mobile/26-aug-25 into staging

Reviewed-on: bip/hipmi#4
This commit is contained in:
2025-08-26 17:44:00 +08:00
3 changed files with 53 additions and 1 deletions

View File

@@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [1.4.30](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.29...v1.4.30) (2025-08-26)
## [1.4.29](https://wibugit.wibudev.com/bip/hipmi/compare/v1.4.28...v1.4.29) (2025-08-25)

View File

@@ -1,6 +1,6 @@
{
"name": "hipmi",
"version": "1.4.29",
"version": "1.4.30",
"private": true,
"prisma": {
"seed": "bun prisma/seed.ts"

View File

@@ -0,0 +1,50 @@
import { NextResponse } from "next/server";
export async function POST(request: Request) {
const contentType = request.headers.get("content-type");
console.log("Incoming Content-Type:", contentType);
const formData = await request.formData();
const file: any = formData.get("file");
const dirId = formData.get("dirId");
console.log("formData >>", formData);
console.log("file >>", file);
console.log("dirId >>", dirId);
try {
const res = await fetch("https://wibu-storage.wibudev.com/api/upload", {
method: "POST",
body: formData,
headers: {
Authorization: `Bearer ${process.env.WS_APIKEY}`,
},
});
const dataRes = await res.json();
if (res.ok) {
console.log(`Success upload ${dirId}: ${JSON.stringify(dataRes.data)}`);
return NextResponse.json(
{ success: true, data: dataRes.data },
{ status: 200 }
);
} else {
const errorText = await res.text();
console.log(`Failed upload ${dirId}: ${errorText}`);
return NextResponse.json(
{ success: false, message: errorText },
{ status: 400 }
);
}
} catch (error) {
return NextResponse.json(
{
success: false,
message: "Failed upload file",
data: error,
},
{ status: 500 }
);
}
}