Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload/Download Progress on Vercel Blob #642

Open
fahidsarker opened this issue Mar 31, 2024 · 4 comments
Open

Upload/Download Progress on Vercel Blob #642

fahidsarker opened this issue Mar 31, 2024 · 4 comments

Comments

@fahidsarker
Copy link

I am currently using vercel blob to store large files and not showing the progress results in a very bad user experience. Can we have this feature soon?

@luismeyer
Copy link
Member

hey @fahidsarker,
this is on our roadmap and we are planning to implement this.

Are you using the multipart upload or the plain put method?

@xavimb
Copy link

xavimb commented Apr 16, 2024

We're having the same issue. We're using the multipart upload, typically with large files.

@patrickdevivo
Copy link

We're also using Vercel Blob and taking the client-side upload approach (in our Next.js app) and would love to show an upload progress bar, especially for larger file uploads.

@jonathantcrawford
Copy link

If you are using @vercel/blob/client package in a NetxtJs app router, I think I have a temp solution.

util.ts

"use server"
import { upload, generateClientTokenFromReadWriteToken } from "@vercel/blob/client";

import { ORIGIN } from "@/lib/constants";




export const secureGenerateClientTokenFromReadWriteToken = async ({
  userId,
  pathname,
}: {
  userId: string;
  pathname: string;
}) => {

  return generateClientTokenFromReadWriteToken({
    token: process.env.BLOB_READ_WRITE_TOKEN,
    pathname: pathname,
    onUploadCompleted: {
      callbackUrl: `${ORIGIN}/api/user/upload`,
      tokenPayload: JSON.stringify({
        userId,
      }),
    }
  })
}

Then from inside your client component.

        const pathname = `${user.id}/${file.name}`;
        const token = await secureGenerateClientTokenFromReadWriteToken({
          userId: user.id,
          pathname,
        });
        await axios.put(
          `https://blob.vercel-storage.com/${pathname}`,
          file,
          {
            headers: {
              "Authorization": `Bearer ${token}`,
            },
            onUploadProgress: (progressEvent) => {
              console.log(progressEvent);
            }
          }
        )
       ```



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@patrickdevivo @xavimb @jonathantcrawford @luismeyer @fahidsarker and others