Skip to content

@vercel/blob - not possible to use client lib in node.js env #638

@pie6k

Description

@pie6k

Use case:

I want to upload files larger than 4.5MB (vercel limit) from node.js enviroment (to be specific - from Electron main process which runs in node env)

I did follow steps at https://vercel.com/docs/storage/vercel-blob/client-upload and it works perfectly fine, but I'm only able to run it from browser env.

If I run it in node env I hit ${methodName} must be called from a client environment error. (

if (typeof window === 'undefined') {
)

I did check the file https://github.com/vercel/storage/blob/5fb6969801107030adbdd156a1a1f2da8414eaad/packages/blob/src/client.ts and it seems to barely be using window, the only real case is

function toAbsoluteUrl(url: string): string {
  return new URL(url, window.location.href).href;
}

I think it might be quite common use case to handle such uploads externally. Is there any particular reason this use-case is restricted to Browser env?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions