Spaces:
Running
Running
Download frontend/src/app/developers/page.tsx from TwanAPI/UploadFile: direct link, hf CLI and curl.
- Browser
- Download file 4.52 kB
-
https://huggingface.co/spaces/TwanAPI/UploadFile/resolve/main/frontend/src/app/developers/page.tsx
- Command line
-
hf download hf://spaces/TwanAPI/UploadFile/frontend/src/app/developers/page.tsx
-
curl -L -o page.tsx https://huggingface.co/spaces/TwanAPI/UploadFile/resolve/main/frontend/src/app/developers/page.tsx
4.52 kB
| "use client"; | |
| import React from "react"; | |
| import { Copy } from "lucide-react"; | |
| import { useCloud } from "@/context/CloudContext"; | |
| import { WorkspaceShell } from "@/components/WorkspaceShell"; | |
| import { NavbarPublic } from "@/components/NavbarPublic"; | |
| export default function DevelopersPage() { | |
| const { token, currentUser, notify } = useCloud(); | |
| const sampleToken = token ? `${token.slice(0, 28)}...` : "<YOUR_BEARER_TOKEN>"; | |
| const content = ( | |
| <div className="p-6 space-y-6 max-w-[1300px] mx-auto"> | |
| <div className="glass-panel rounded-3xl p-6 sm:p-8 border border-indigo-500/30"> | |
| <span className="px-2.5 py-0.5 rounded-full text-[10px] font-mono font-bold uppercase bg-indigo-500/20 text-indigo-300 border border-indigo-500/30"> | |
| Developer Hub • /developers | |
| </span> | |
| <h1 className="text-2xl font-extrabold text-white mt-1">Tích hợp REST API & Bearer Token</h1> | |
| <p className="text-xs sm:text-sm text-slate-300 mt-1"> | |
| Sử dụng Session Token hiện tại của bạn hoặc <code className="text-indigo-300">X-API-Key</code> để tự động hóa | |
| việc tải lên, liệt kê và tải xuống tệp từ terminal hoặc ứng dụng CI/CD bên ngoài. | |
| </p> | |
| {token && ( | |
| <div className="mt-4 p-4 rounded-2xl bg-slate-950/90 border border-white/10 flex items-center justify-between gap-4"> | |
| <div className="min-w-0"> | |
| <p className="text-[11px] font-mono text-slate-400">BEARER TOKEN CỦA BẠN (Hiệu lực 7 ngày)</p> | |
| <p className="text-xs font-mono text-emerald-300 truncate mt-0.5">{token}</p> | |
| </div> | |
| <button | |
| onClick={() => { | |
| navigator.clipboard.writeText(token); | |
| notify("Đã sao chép Bearer Token!", "success"); | |
| }} | |
| className="px-3.5 py-2 rounded-xl bg-white/10 hover:bg-white/15 text-xs font-semibold text-white shrink-0 flex items-center gap-1.5" | |
| > | |
| <Copy className="w-3.5 h-3.5" /> Sao chép Token | |
| </button> | |
| </div> | |
| )} | |
| </div> | |
| <div className="grid grid-cols-1 lg:grid-cols-2 gap-6"> | |
| {[ | |
| { | |
| title: "1. Liệt kê danh sách tệp (theo quyền User/Admin)", | |
| method: "GET /api/files", | |
| code: `curl -s "http://localhost:8080/api/files" \\\n -H "Authorization: Bearer ${sampleToken}"`, | |
| }, | |
| { | |
| title: "2. Tải tệp mới lên Upload ThTuanIT (Turbo Upload)", | |
| method: "POST /api/upload", | |
| code: `curl -X POST "http://localhost:8080/api/upload" \\\n -H "Authorization: Bearer ${sampleToken}" \\\n -F "path=media/video.mp4" \\\n -F "file=@./video.mp4"`, | |
| }, | |
| { | |
| title: "3. Đổi tên / Di chuyển đường dẫn tệp (Zero-Copy Hash)", | |
| method: "PUT /api/files", | |
| code: `curl -X PUT "http://localhost:8080/api/files" \\\n -H "Authorization: Bearer ${sampleToken}" \\\n -H "Content-Type: application/json" \\\n -d '{"old_path":"media/video.mp4","new_path":"archive/video-2026.mp4"}'`, | |
| }, | |
| { | |
| title: "4. Tải tệp xuống hoặc Streaming HTTP Range", | |
| method: "GET /api/download", | |
| code: `curl -L "http://localhost:8080/api/download?path=111.mp4" \\\n -H "Authorization: Bearer ${sampleToken}" \\\n -o 111.mp4`, | |
| }, | |
| ].map((snip, idx) => ( | |
| <article key={idx} className="glass rounded-3xl p-5 border border-white/10 flex flex-col justify-between"> | |
| <div> | |
| <div className="flex items-center justify-between mb-3"> | |
| <h2 className="text-sm font-bold text-white">{snip.title}</h2> | |
| <span className="px-2 py-0.5 rounded text-[10px] font-mono bg-indigo-500/20 text-indigo-300 border border-indigo-500/30"> | |
| {snip.method} | |
| </span> | |
| </div> | |
| <pre className="p-4 rounded-2xl bg-slate-950/90 border border-white/5 text-xs font-mono text-slate-300 overflow-x-auto"> | |
| {snip.code} | |
| </pre> | |
| </div> | |
| </article> | |
| ))} | |
| </div> | |
| </div> | |
| ); | |
| if (!currentUser) { | |
| return ( | |
| <div className="min-h-screen flex flex-col bg-grid-pattern"> | |
| <NavbarPublic /> | |
| <main className="flex-1 py-6">{content}</main> | |
| </div> | |
| ); | |
| } | |
| return <WorkspaceShell>{content}</WorkspaceShell>; | |
| } | |