diff --git a/CHANGELOG.md b/CHANGELOG.md index dc61f3d3..d1524766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/package.json b/package.json index 62ebdc1f..cc22a5e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hipmi", - "version": "1.4.29", + "version": "1.4.30", "private": true, "prisma": { "seed": "bun prisma/seed.ts" diff --git a/src/app/api/mobile/upload/route.ts b/src/app/api/mobile/upload/route.ts new file mode 100644 index 00000000..10af0cd3 --- /dev/null +++ b/src/app/api/mobile/upload/route.ts @@ -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 } + ); + } +}