cleanup upload-component pt2
This commit is contained in:
@ -14,6 +14,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
||||
import { Copy, Check, ExternalLink, FileImage, Clock, Database, ArrowLeft } from "lucide-react"
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"
|
||||
import { Spinner } from "./spinner"
|
||||
import { createHash } from "crypto"
|
||||
|
||||
interface UploadResponse {
|
||||
url: string
|
||||
@ -231,32 +232,7 @@ const UploadResponseView = ({ data, onReset }: { data: UploadResponse; onReset:
|
||||
)
|
||||
}
|
||||
|
||||
async function calculateBlurhash(file: File): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const canvas = document.createElement("canvas")
|
||||
const ctx = canvas.getContext("2d")
|
||||
const img = new Image()
|
||||
img.crossOrigin = "anonymous"
|
||||
img.onload = () => {
|
||||
canvas.width = 32
|
||||
canvas.height = 32
|
||||
ctx?.drawImage(img, 0, 0, 32, 32)
|
||||
const imageData = ctx?.getImageData(0, 0, 32, 32)
|
||||
if (imageData) {
|
||||
// Mock blurhash calculation - in a real app you'd use the blurhash library
|
||||
const mockBlurhash = "LGF5?xYk^6#M@-5c,1J5@[or[Q6."
|
||||
resolve(mockBlurhash)
|
||||
} else {
|
||||
reject(new Error("Failed to get image data"))
|
||||
}
|
||||
}
|
||||
img.onerror = reject
|
||||
img.src = URL.createObjectURL(file)
|
||||
})
|
||||
}
|
||||
|
||||
const UploadComponent = () => {
|
||||
const { createHash } = require("crypto")
|
||||
const loginType = typeof window !== "undefined" ? window.localStorage.getItem("loginType") : null
|
||||
const [previewUrl, setPreviewUrl] = useState("")
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
Reference in New Issue
Block a user