Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: update @vercel/blob dep
Marc Seitza1497121a7d3
diff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsxindex 6912b25f..7b6f52b0 100644--- a/components/documents/add-document-modal.tsx+++ b/components/documents/add-document-modal.tsx@@ -8,7 +8,8 @@ import {} from "@/components/ui/dialog";import { useState } from "react";import { useRouter } from "next/router";-import { put, type PutBlobResult } from "@vercel/blob";+import { type PutBlobResult } from "@vercel/blob";+import { upload } from '@vercel/blob/client';import DocumentUpload from "@/components/document-upload";import { pdfjs } from "react-pdf";import { copyToClipboard, getExtension } from "@/lib/utils";@@ -35,9 +36,9 @@ export function AddDocumentModal({children}: {children: React.ReactNode}) {try {setUploading(true);- const newBlob = await put(currentFile.name, currentFile, {+ const newBlob = await upload(currentFile.name, currentFile, {access: "public",- handleBlobUploadUrl: "/api/file/browser-upload",+ handleUploadUrl: "/api/file/browser-upload",});let response: Response | undefined;diff --git a/components/welcome/upload.tsx b/components/welcome/upload.tsxindex dec6971e..64f0de6c 100644--- a/components/welcome/upload.tsx+++ b/components/welcome/upload.tsx@@ -1,7 +1,8 @@import { useRouter } from "next/router";import { motion } from "framer-motion";import { useState } from "react";-import { put, type PutBlobResult } from "@vercel/blob";+import { type PutBlobResult } from "@vercel/blob";+import { upload } from "@vercel/blob/client";import DocumentUpload from "@/components/document-upload";import { ArrowRightIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline";import { toast } from "sonner";@@ -37,9 +38,9 @@ export default function Upload() {try {setUploading(true);- const newBlob = await put(currentFile.name, currentFile, {+ const newBlob = await upload(currentFile.name, currentFile, {access: "public",- handleBlobUploadUrl: "/api/file/browser-upload",+ handleUploadUrl: "/api/file/browser-upload",});setCurrentFile(null);diff --git a/package-lock.json b/package-lock.jsonindex 6edfa6e7..2122988e 100644--- a/package-lock.json+++ b/package-lock.json@@ -32,7 +32,7 @@"@types/react": "^18.2.23","@types/react-dom": "^18.2.8","@vercel/analytics": "^1.0.2",- "@vercel/blob": "^0.10.0",+ "@vercel/blob": "^0.12.5","autoprefixer": "^10.4.16","base-x": "^4.0.0","bcryptjs": "^2.4.3",@@ -3048,12 +3048,12 @@"integrity": "sha512-BZFxVrv24VbNNl5xMxqUojQIegEeXMI6rX3rg1uVLYUEXsuKNBSAEQf4BWEcjQDp/8aYJOj6m8V4PUA3x/cxgg=="},"node_modules/@vercel/blob": {- "version": "0.10.0",- "resolved": "https://registry.npmjs.org/@vercel/blob/-/blob-0.10.0.tgz",- "integrity": "sha512-ypRO1Q0mil2FjvNCZDGmOBrdARuuR+FpV4MKkQvFvHiyc2K6EB16XmrFOdmHojPiof172NL4b1Y6hpfbUtq5IA==",+ "version": "0.12.5",+ "resolved": "https://registry.npmjs.org/@vercel/blob/-/blob-0.12.5.tgz",+ "integrity": "sha512-XCsg9W2WrDlQGnw9X38RbM2mtfhTvp4x9lThx4Cr496c0f4IIoMbuwiFd9uvu228D+RcyeopTN7KJAUERCSogw==","dependencies": {- "jest-environment-jsdom": "29.6.1",- "undici": "5.22.1"+ "jest-environment-jsdom": "29.7.0",+ "undici": "5.24.0"},"engines": {"node": ">=16.14"@@ -12592,12 +12592,12 @@"integrity": "sha512-BZFxVrv24VbNNl5xMxqUojQIegEeXMI6rX3rg1uVLYUEXsuKNBSAEQf4BWEcjQDp/8aYJOj6m8V4PUA3x/cxgg=="},"@vercel/blob": {- "version": "0.10.0",- "resolved": "https://registry.npmjs.org/@vercel/blob/-/blob-0.10.0.tgz",- "integrity": "sha512-ypRO1Q0mil2FjvNCZDGmOBrdARuuR+FpV4MKkQvFvHiyc2K6EB16XmrFOdmHojPiof172NL4b1Y6hpfbUtq5IA==",+ "version": "0.12.5",+ "resolved": "https://registry.npmjs.org/@vercel/blob/-/blob-0.12.5.tgz",+ "integrity": "sha512-XCsg9W2WrDlQGnw9X38RbM2mtfhTvp4x9lThx4Cr496c0f4IIoMbuwiFd9uvu228D+RcyeopTN7KJAUERCSogw==","requires": {- "jest-environment-jsdom": "29.6.1",- "undici": "5.22.1"+ "jest-environment-jsdom": "29.7.0",+ "undici": "5.24.0"}},"abab": {diff --git a/package.json b/package.jsonindex 2732a26d..7b1ae741 100644--- a/package.json+++ b/package.json@@ -38,7 +38,7 @@"@types/react": "^18.2.23","@types/react-dom": "^18.2.8","@vercel/analytics": "^1.0.2",- "@vercel/blob": "^0.10.0",+ "@vercel/blob": "^0.12.5","autoprefixer": "^10.4.16","base-x": "^4.0.0","bcryptjs": "^2.4.3",diff --git a/pages/api/file/browser-upload.ts b/pages/api/file/browser-upload.tsindex 52163d68..e813c063 100644--- a/pages/api/file/browser-upload.ts+++ b/pages/api/file/browser-upload.ts@@ -1,4 +1,4 @@-import { handleBlobUpload, type HandleBlobUploadBody } from "@vercel/blob";+import { handleUpload, type HandleUploadBody } from "@vercel/blob/client";import type { NextApiResponse, NextApiRequest } from "next";import { getServerSession } from "next-auth/next";import { authOptions } from "../auth/[...nextauth]";@@ -8,10 +8,10 @@ export default async function handler(req: NextApiRequest,res: NextApiResponse) {- const body = JSON.parse(req.body) as HandleBlobUploadBody;+ const body = JSON.parse(req.body) as HandleUploadBody;try {- const jsonResponse = await handleBlobUpload({+ const jsonResponse = await handleUpload({body,request: req,onBeforeGenerateToken: async (pathname: string) => {@@ -32,16 +32,16 @@ export default async function handler(}),};},- onUploadCompleted: async ({ blob, metadata }) => {+ onUploadCompleted: async ({ blob, tokenPayload }) => {// Get notified of browser upload completion// ⚠️ This will not work on `localhost` websites,// Use ngrok or similar to get the full upload flow- console.log("blob upload completed", blob, metadata);+ console.log("blob upload completed", blob, tokenPayload);try {// Run any logic after the file upload completed- // const { userId } = JSON.parse(metadata);+ // const { userId } = JSON.parse(tokenPayload);// await db.update({ avatar: blob.url, userId });} catch (error) {// throw new Error("Could not update user");