vercel / storage

Vercel Postgres, KV, Blob, and Edge Config
https://vercel.com/storage
Apache License 2.0
502 stars 56 forks source link

Upload/Download Progress on Vercel Blob #642

Open fahidsarker opened 6 months ago

fahidsarker commented 6 months ago

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 commented 5 months ago

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 commented 5 months ago

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

patrickdevivo commented 5 months ago

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 commented 5 months ago

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);
            }
          }
        )
Vitalii-Hurieiev commented 3 months ago

This progress functionality is important for our project as well. Displaying the download progress is essential for users, as varying file sizes or slow internet connections can make the process appear frozen.

alan-funded commented 2 months ago

Important for us also, we have mobile users thinking the upload did not work, and uploading a second time.

neoromantic commented 1 week ago

Any idea on whether it'll be implemented anytime soon?

I need to understand should I move to S3 uploads instead of Vercel Blob or not.