- Updated .env.example to include configuration for OnlyOffice Document Server. - Modified the workspace configuration to remove the drive-suite path. - Adjusted TypeScript environment imports for consistency. - Enhanced Next.js configuration to disable canvas in Webpack. - Updated package.json to include new dependencies for OnlyOffice and PDF.js. - Added global styles for OnlyOffice theme integration in the CSS. - Created new layout and page components for the Drive feature, including public sharing and editing functionalities. - Updated metadata handling across various layouts to reflect the new app structure.
24 lines
776 B
TypeScript
24 lines
776 B
TypeScript
import { useAuthStore } from "@/lib/api/auth-store"
|
|
|
|
const API_BASE = process.env.NEXT_PUBLIC_API_URL ?? "/api/v1"
|
|
|
|
export async function uploadFile(targetPath: string, file: File, onProgress?: (pct: number) => void) {
|
|
const token = useAuthStore.getState().accessToken
|
|
const path = targetPath.startsWith("/") ? targetPath : `/${targetPath}`
|
|
const url = `${API_BASE}/drive/files${path}`
|
|
|
|
const res = await fetch(url, {
|
|
method: "POST",
|
|
headers: {
|
|
Authorization: token ? `Bearer ${token}` : "",
|
|
"Content-Type": file.type || "application/octet-stream",
|
|
},
|
|
body: file,
|
|
})
|
|
if (!res.ok) {
|
|
const err = await res.json().catch(() => ({}))
|
|
throw new Error((err as { message?: string }).message ?? res.statusText)
|
|
}
|
|
onProgress?.(100)
|
|
}
|